Declares a named parameter for use within an xsl:stylesheet or xsl:template. Allows specification of a default value.
<xsl:param name = Qname select = expression> </xsl:param>
Number of occurrences | Unlimited |
Parent elements | xsl:stylesheet, xsl:template, xsl:transform |
Child elements | xsl:apply-templates, xsl:attribute, xsl:choose, xsl:comment, xsl:copy, xsl:copy-of, xsl:element, xsl:for-each, xsl:if, xsl:processing-instruction, xsl:text, xsl:value-of, xsl:variable, output elements |
The value specified on the <xsl:param> element is a default value for binding. When the template or style sheet containing <xsl:param> is invoked, parameters are passed that are used in place of the default values.
The value of the parameter can be an object of any type that can be returned by an expression. The <xsl:param> element can specify the value of the variable in three alternative ways:
An error occurs if a member of the sequence of nodes created by instantiating the template is an attribute node or a namespace node, because a root node cannot have an attribute node or a namespace node as a child.
<xsl:
paramname="x"/>
is equivalent to
<xsl:param name="x" select="''"/>
Note When a parameter is used to select nodes by position, be careful not to do the following:
<xsl:param name="n">2</xsl:param> ... <xsl:value-of select="item[$n]"/>
This will output the value of the first item element, because the variable "n" will be bound to a result tree fragment, not a number. Instead, do either
<xsl:param name="n" select="2"/> ... <xsl:value-of select="item[$n]"/>
or
<xsl:param name="n">2</xsl:param> ... <xsl:value-of select="item[number($n)]"/>
Note One convenient way to specify the empty node-set as the default value of a parameter is:
<xsl:param name="x" select="/.."/>