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
