Specifying Patterns for the match Attribute

You can use an involved syntax with the <xsl:template> element's match attribute, and you can use an even more involved syntax with the select attribute of the <xsl:apply-templates>, <xsl:value-of>, <xsl:for-each>, <xsl:copy-of>, and <xsl:sort> elements. We'll see them both in this chapter, starting with the syntax you can use with the match attribute.

Matching the Root Node

As we've already seen, you can match the root node with /, like this:

						<xsl:template match="/"> 
    <HTML>
        <xsl:apply-templates/>
    </HTML>
 </xsl:template>

Matching Elements

You can match elements simply by giving their name, as we've also seen:

						<xsl:template match="PLANETS"> 
  <HTML>
    <xsl:apply-templates/>
  </HTML>
</xsl:template>

Get Real World XML 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.