dotnet thoughts 

a dotnet developer's technical blog

Passing parameters to XSL

While transforms in XML using XSL, some time it requires to pass runtime parameters to XSL.

You can create the parameters in XSL like this

<xsl:param name="title" />

And you can use the parameters as normal variables

<xsl:value-of select="$title" />

In code you need a class from System.Xml.Xsl namespace to pass the parameters as Arguments.

XsltArgumentList _RuntimeParams = new XsltArgumentList();
_RuntimeParams.AddParam("title","","Using XML - XSL Convertion");

XslTransform Transform = new XslTransform();
Transform.Load(stylesheet);

XPathDocument XmlDoc = new XPathDocument(filename);
XmlTextWriter OutputWriter = new XmlTextWriter(“MyReport.html”,null);

xslt.Transform(XmlDoc, _RuntimeParams, OutputWriter);

For more information look Url :XsltArgumentList in MSDN