O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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>

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required