Default Template Rules
Take a look at the following XSLT stylesheet; it has rules that match the root node, <PLANETS> nodes, and <PLANET> nodes:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <HTML> <xsl:apply-templates/> </HTML> </xsl:template> <xsl:template match="PLANETS"> <xsl:apply-templates/> </xsl:template> <xsl:template match="PLANET"> <P> <xsl:value-of select="NAME"/> </P> </xsl:template> </xsl:stylesheet>
Note the rule for the <PLANETS> element; that rule simply uses <xsl:apply-templates> to apply templates to all its child nodes. However, there is a default rule in template processing that if you don’t supply a rule for an element, <apply-templates/> ...
Get Inside XSLT 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.