I’m trying to find an easy way to pass parameters from my C# class file (.cs) to my .xslt file. I’m not really working with a .xml file, so I don’t know if something like this http://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltargumentlist.addparam.aspx will work for me. Also, I don’t have a main method since it is just a class (this is all being done in .net). Does anybody know of a possible way to do this?
protected void Page_Load(object sender, EventArgs e)
{
XsltSettings settings = new XsltSettings();
settings.EnableScript = true;
FetchQuote();
// Create the XslCompiledTransform and load the stylesheet
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("Home.xslt");
// Create the XsltArgumentList
XsltArgumentList xslArg = new XsltArgumentList();
// Add parameters
xslArg.AddParam("chart_url", "","Chart_Url");
xslArg.AddParam("last", "", "Last");
xslArg.AddParam("change", "", "Change");
xslArg.AddParam("perc_change", "", "Perc_Change");
// Transform the File
using (XmlWriter w = XmlWriter.Create("output.xml"))
{
xslt.Transform("", xslArg, w);
}
}
xsl: