Chooses the next template to execute.

Category: instruction
Content: ( xsl:with-param | xsl:fallback )*
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 2.0 and later versions. Available in all Saxon editions. Available for all platforms.


The xsl:next-match instruction was introduced in XSLT 2.0. It is very similar to xsl:apply-imports, but with a different algorithm for choosing the next template to execute. It chooses the template rule that matches the current node and that would have been chosen if the current template rule and all higher precedence/priority rules were not there.

In practice xsl:next-match is nearly always preferable to xsl:apply-imports since the rules for using it are much more flexible and more intuitive.

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