Name

[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.

Category

Instruction.

Required Attributes

None.

Optional Attributes

None.

Content

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.”

Example

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

<!-- element-discussion.html -->
<html>
  <head>
    <title>Interesting new XSLT elements</title>
  </head>
  <body>
    <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>
  </body>
</html>

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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.