January 2003
Beginner to intermediate
1200 pages
23h 42m
English
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 ...