xsl:param
Declares a parameter on a template, function, or at the stylesheet level.
<xsl:param name="page-size" select="'A4'"/>A parameter is like a variable, but its value can be supplied by the caller — via xsl:with-param for templates, via positional arguments for functions, or via TransformOptions.Parameters for top-level (stylesheet) parameters. If no value is supplied, the select expression or body provides a default. If neither is given, the default is the empty sequence.
xsl:param must appear before any other content in its container. For functions, every xsl:param is required (no defaults).
Attributes
| Attribute | Description |
|---|---|
name |
Parameter name. Required. |
select |
XPath expression for the default value. |
as |
Sequence type the parameter is coerced to. |
required |
yes to make the parameter required (no default). |
tunnel |
yes to declare a tunnel parameter — receives matching tunnel parameters from xsl:with-param. |
Examples
Top-level (global) parameter — settable from the API or CLI:
<xsl:param name="lang" select="'en'"/>Template parameter with a default:
<xsl:template name="greet">
<xsl:param name="who" select="'World'"/>
<p>Hello <xsl:value-of select="$who"/></p>
</xsl:template>Required typed parameter:
<xsl:template match="item">
<xsl:param name="indent" as="xs:integer" required="yes"/>
...
</xsl:template>