Aug 18, 2007

xslt parameter

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="Age" ></xsl:param>
<xsl:template match="/">
<html>
<body>
<xsl:value-of  select="$Age"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XmlTextWriter xmlwriter = new XmlTextWriter(writer);
XsltArgumentList list = new XsltArgumentList();
list.AddParam("Age", "", "108");
xslt.Transform(doc, list, xmlwriter);

Parameter of a template

<xsl:apply-templates select="$castList" mode="DisplayToggle">
            <xsl:with-param name="divID" select="$programID" />
            </xsl:apply-templates>

            <xsl:template match="CastList" 

Basically parameter can be used variable, and constructed as variable. The difference is used with template. The "xsl:with-param" element is optional, if it is not defined, the default value of "xsl:param" will be used.

<xsl:apply-templates select="$orderRow">
<xsl:with-param name="sn1" select="1" />
</xsl:apply-templates>
<xsl:template match="Row">
<xsl:param name="sn" select="2"></xsl:param>
<xsl:param name="sn1" select="$sn"></xsl:param>