xsl:apply-imports

Searches for a template that matches the current node and that is defined in a stylesheet that was imported (directly or indirectly) from the stylesheet containing the current template, and whose mode matches the current mode. If there is such a template, it is activated using the current node. If not, the built-in template for the kind of node is activated.

Category: instruction
Content: xsl:with-param*
Permitted parent elements: any XSLT element whose content model is sequence-constructor; any literal result element
Element has no attributes

Saxon availability

Available in XSLT 1.0 and later versions. Available in all Saxon editions. Available for all platforms.

Details

At run-time, there must be a current template. A current template is established when a template is activated as a result of a call on xsl:apply-templates. Calling xsl:call-template does not change the current template. Calling xsl:for-each or xsl:for-each-group causes the current template to become null.

The xsl:apply-imports element is used in conjunction with imported stylesheets. The effect is to search for a template that matches the current node and that is defined in a stylesheet that was imported (directly or indirectly, possibly via xsl:include) from the stylesheet containing the current template, and whose mode matches the current mode. If there is such a template, it is activated using the current node. If not, the built-in template for the kind of node is activated.

To supply parameters to the called template, one or more xsl:with-param elements may be included. The values of these parameters are available to the called template. If the xsl:with-param element specifies tunnel="yes", then the parameter is passed transparently through to templates called at any depth, but it can only be referenced by an xsl:param element that also specifies tunnel="yes". If the default value, tunnel="no" is used, then the parameter value is available only in the immediately called template, and only if the xsl:param element specifies tunnel="no" (explicitly or by defaulting the attribute).

Links to W3C specifications

XSLT 2.0 Specification

XSLT 3.0 Specification

See also

xsl:import

xsl:next-match

xsl:param

xsl:with-param