xsl:with-param

0
7
<xsl:with-param>
<xsl:with-param name=”qname” >

</xsl:param>

Or:

<xsl:with-param name=”qname” select=”expression” />

The xsl:with-param element is used to set the explicit value of a named parameter when using thexsl:apply-templates and the xsl:call-template elements.
The concept is that the xsl:param element is used to declare a local or global parameter by assigning a name and a default value. The xsl:with-param element is used to set the actual (explicit) value which will be used in place of the default value.
The name cited by the xsl:with-param element must match a name in an xsl:param element. If there is no such match, the xsl:with-param element is simply ignored, but it is not treated as an error.
Like all XSLT elements, the xsl:with-param element must be closed (well-formed). If the select attribute is present, then this element is self-closing. If the select attribute is not present, then this element is not self-closing and the separate closing element is mandatory.
name=”qname”
The mandatory name attribute is the qname of the expression. A qname is a qualified name that is composed of an optional namespace prefix, a colon which is only present if there is a prefix, and a mandatory XML name (for example, xsl:zipcode or zipcode).
Note the following rules concerning when two different parameters can have the same name. (The same rules apply to the name attribute of the xsl:param element.)
• A name can be repeated if one of the names is in an imported stylesheet and therefore has a lower import precedence. Under these circumstances, the higher import precedence name will always have precedence.
• Two different parameters can have the same name if they can never occur within the same scope. Therefore no ambiguity can occur (which would be an error).
• A local and global parameter can have the same name. However, when the local parameter is in scope, the global parameter cannot be accessed.
If the with-param element contains no content and a select attribute has been not assigned, then the named parameter is set to be the empty string.
select=”expression”
The optional select attribute is an expression that defines the parameter. If the select attribute is present, then the xsl:with-param element cannot contain any content and is self-closing. If an expression is given, the data type must be Boolean, node-set, number or string.
If it is a (literal) string, the string must be enclosed within opening and closing quotes and in turn, that default value must be enclosed again in opening and closing quotes. For example:
<xsl:with-param name=”car” select=” ‘ Ford ‘ ” />
Or
<xsl:with-param name=”car” select=’ ” Ford ” ‘ />
If the name attribute is assigned, a select attribute is not assigned, and there is no content, then the named parameter is set to be the empty string for the default value.