Table of contents

Abstract

Introduction

The basic concepts

Stylesheet organization

Root template

Match processing instruction nodes

Match text nodes

Match attributes

Match other nodes

Keepspace template

Using the stylesheet

The complete stylesheet

Root template

The root template handles the document root, inserts a DOCTYPE declaration (through a named template), and invokes <xsl:apply-templates> for all nodes, using the identity mode. This mode is used for almost all other templates (other than keepspace).

<xsl:template match="/">
    <xsl:message>Handling whitespace.</xsl:message>
    <xsl:call-template name="add_doctype"/>
    <xsl:apply-templates select="node()" mode="identity"/>
</xsl:template>

The message “Handling whitespace.” is useful in initial testing. When things are up and running correctly, you can delete or comment out this message.

For more information about the template that adds the DOCTYPE declaration, see my blog post Adding a DOCTYPE declaration on XML output.

 

 

Next Page:
Match processing instruction nodes


Scriptorium Publishing | Post Office Box 12761 Research Triangle Park, NC 27709 | (919) 481 2701 | info@scriptorium.com