Home >
Online Product Documentation >
Table of Contents >
xsl:param
xsl:param
Declares a parameter for a stylesheet or template, and specifies a default value for the parameter.
Format
Description
The
xsl:param
instruction declares a parameter and specifies its default value. Another value can be passed to this parameter when the template or stylesheet that contains this
xsl:param
instruction is invoked.
The
xsl:param
element must be a child of either an
xsl:stylesheet
or
xsl:template
element.
The
name
attribute is required, and it must be a string. The value of the
name
attribute is a qualified name.
The value that you bind to a parameter can be an object of any of the types that are returned by expressions. You can specify the value of the parameter in several ways:
- Specify the
select
attribute. The value of the
select
attribute must be an expression. The XSLT processor evaluates the expression, and the result is the default value of the parameter. If you specify the
select
attribute, the XSLT processor ignores any value you might specify for the
expr
attribute, and also ignores any contents of
xsl:param
.
- Specify the
expr
attribute. The
expr
attribute allows computation of an expression. For example:
The XSLT processor interprets the value of the
expr
attribute as an attribute value template and uses the resulting string as if it were the value of the
select
attribute. If you specify the
expr
attribute, the XSLT processor ignores any contents of
xsl:param
.
The use of the
expr
attribute is an extension to the XSLT specification.
- Specify template_body. The XSLT processor instantiates this template to obtain the default value of the parameter.
- If you do not specify the
select
attribute, the
expr
attribute, or template_body, the default value of the parameter is an empty string.
For any use of the
xsl:param
element, there is a region of the stylesheet tree within which the binding is visible. This region includes the siblings that follow the
xsl:param
instruction together with their descendants. Within this region, any binding of the parameter that was visible on the
xsl:param
element itself is hidden. Thus, only the innermost binding of a parameter is visible. The set of parameter bindings in scope for an expression consists of those bindings that are visible at the point in the stylesheet where the expression occurs.
The
xsl:param
instruction can be a top-level element. If it is, it declares a global parameter that is visible to the entire stylesheet. When the XSLT processor evaluates the
select
or
expr
attribute in a top-level
xsl:param
instruction, the current node is the root node of the document.
Passing parameters to templates
Use the
xsl:with-param
instruction to pass a value for a parameter to a template.