[2.0] <xsl:next-match>

Tells the XSLT processor to select a template that is the next lowest in priority than the current template. This works similarly to <xsl:apply-imports>, although <xsl:next-match> works with all templates, including those in the main stylesheet and in any stylesheets included or imported. Using <xsl:next-match> allows you to set up templates that work like overridden methods in object-oriented languages; using <xsl:next-match> is conceptually the same as calling super() in a Java program.



Required Attributes


Optional Attributes



Any number of <xsl:with-param> and <xsl:fallback> elements.

Appears in

<xsl:next-match> appears inside a template.

Defined in

[2.0] XSLT section 6.7, “Overriding Template Rules.”


For our example, we’ll create some templates to process this HTML document:

<!-- element-discussion.html -->
    <title>Interesting new XSLT elements</title>
    <h1>Interesting new XSLT elements</h1>
    <p>XSLT 2.0 has lots of interesting new elements. 
    We'll mention a couple of them here. </p>
    <h1>The <code>&lt;xsl:next-match&gt;</code> element</h1>
    <p>One of the most interesting new elements in XSLT 2.0 
    is <code>&lt;xsl:next-match&gt;</code>. </p>
    <h1>The <code>&lt;xsl:perform-sort&gt;</code> element</h1>
    <p>Don't forget about <code>&lt;xsl:perform-sort&gt;</code>,
    though.  It's very interesting as well.</p>

Our example document has HTML <code> elements. Some of them are inside <h1> elements, ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.