Built-in Templates

The November 1999 XSL Transformations (XSLT) Recommendation includes two built-in templates, which are included in the Microsoft® XSLT processor. These templates make it easier to create style sheets for irregular data by passing text from the source document to the output automatically.

The built-in template included in the Microsoft XSLT processor for element nodes and the root node looks like the following code example.

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

The built-in template for text and attribute nodes is as shown in the following code example.

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

The built-in template for processing instructions and comments is to take no action, as shown in the following code example.

<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.

See Also

Advanced XSLT Features

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.