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

The Default XSLT Rules

XSLT has some built-in, default rules that we've already seen in action. For example, the default rule for text nodes is to add the text in that node to the output document.

The most important default rule applies to elements and can be expressed like this:

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

This rule is simply there to make sure that every element, from the root on down, is processed with <xsl:apply-templates/> if you don't supply some other rule. If you do supply another rule, it overrides the corresponding default rule.

The default rule for text can be expressed like this, where by default, the text of a text node is added to the output document:

 <xsl:template match="text()"> <xsl:value-of ...

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