Using the Built-in Template Rules

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Developer's Guide

Using the Built-in Template Rules

MSXML versions 4.0 and later support the following two built-in template rules, as recommended by the November 1999 XSLT Recommendation. These templates make it easier to create style sheets for irregular data by passing text from the source document to the output automatically.

The first such built-in template rule is for element nodes and the root node. It works like this:

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

The second built-in template rule is for text and attribute nodes. It works as follows:

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

The built-in template for processing instructions and comments does nothing, as shown in the following:

<xsl:template match="processing-instruction()|comment()"/>

On their own, these templates provide for a complete, though simple, transformation of the source document. Elements and the document root are traversed, although they do not generate any output themselves. The values of text nodes and CDATA sections are passed through. Comments and processing instructions are not processed and thus do not appear in the output. The end result is that these templates by themselves strip all markup from the source document but preserve the text.

To override these built-in templates, specify your own templates in the style sheet so that every node is handled.