Microsoft XML 2.5 SDK


 

Simulating Built-in Templates

[This is preliminary documentation and subject to change.]

The December 1998 XSL Working Draft includes two built-in templates. These templates make it easier to create style sheets for irregular data by passing text from the source document to the output automatically.

Microsoft® Internet Explorer 5 does not have these templates built in but they are easily added to a style sheet without affecting the use of the style sheet by other XSL processors. Other processors will simply use the templates you specify instead of their own built-in templates.

The built-in templates in the XSL Working Draft look like this:

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

Place these templates at the start of the style sheet (before any other templates), otherwise they might prevent XSL from choosing the other templates in your style sheet.

On their own, these templates provide for a complete (albeit 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.