XSLT Elements

XSLT defines 36 elements, which break down into three overlapping categories:

  • Two root elements:

    xsl:stylesheet
    xsl:transform
  • Twelve top-level elements, which may appear as immediate children of the root and are the following:

    xsl:attribute-set          xsl:decimal-format
    xsl:import                 xsl:include
    xsl:key                    xsl:namespace-alias
    xsl:output                 xsl:param
    xsl:preserve-space         xsl:strip-space
    xsl:template               xsl:variable
  • Twenty-two instruction elements, which appear in the content of elements that contain templates. Here, we don’t mean the xsl:template element. We mean the content of that and several other elements, such as xsl:for-each and xsl:message, which are composed of literal result elements, character data, and XSLT instructions that are processed to produce part of the result tree. These elements are as follows:

    xsl:apply-imports          xsl:apply-templates
    xsl:attribute              xsl:call-template
    xsl:choose                 xsl:comment
    xsl:copy                   xsl:copy-of
    xsl:element                xsl:fallback
    xsl:for-each               xsl:if
    xsl:message                xsl:number
    xsl:otherwise              xsl:processing-instruction 
    xsl:sort                   xsl:text
    xsl:value-of               xsl:variable
    xsl:with-param             xsl:when

Most XSLT processors also provide various nonstandard extension elements and allow you to write your own extension elements in languages such as Java and JavaScript.

Elements in this section are arranged alphabetically from xsl:apply-imports to xsl:with-param. Each element begins with a synopsis in the following form:

<xsl:elementName
               attribute1 = "allowed attribute values"
   attribute2 = "allowed attribute ...

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.