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

No related content found.

This entry was posted in .Net. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>