Built in Templates

The following 4 templates are always considered to be part of the XSLT stylesheet these templates allow to continue recursive processing in the absence of a successful pattern match by an user-defined template rule in the stylesheet.

  • A template that will make sure processing is continued when encountering any node (including root).

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="*|/">
        <xsl:apply-templates/>
      </xsl:template>
    </xsl:stylesheet>
    					
  • A template that will make sure processing is continued using the same mode value.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="*|/" mode="m">
        <xsl:apply-templates mode="m"/>
      </xsl:template>
    </xsl:stylesheet>
    					
  • A template rule for text and attribute nodes that copies text through.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="text()|@*">
        <xsl:value-of select="."/>
      </xsl:template>
    </xsl:stylesheet>
    					
  • A template rule for processing instructions and comments that does nothing.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="processing-instruction()|comment()"/>
    </xsl:stylesheet>