Stylus Studio XML Editor

Table of contents

Appendices

2.2 Stylesheet Element

Stylesheet Element

< stylesheet
   id= id
   extension-element-prefixes= tokens
   exclude-result-prefixes= tokens
   version= number >
   <-- Content: import* -->
< /stylesheet>

< transform
   id= id
   extension-element-prefixes= tokens
   exclude-result-prefixes= tokens
   version= number >
   <-- Content: import* -->
< /transform>

A stylesheet is represented by an xsl:stylesheet element in an XML document. xsl:transform is allowed as a synonym for xsl:stylesheet.

An xsl:stylesheet element must have a version attribute, indicating the version of XSLT that the stylesheet requires. For this version of XSLT, the value should be 1.0. When the value is not equal to 1.0, forwards-compatible processing mode is enabled (see [Forwards-Compatible Processing]).

The xsl:stylesheet element may contain the following types of elements:

  • xsl:import

  • xsl:include

  • xsl:strip-space

  • xsl:preserve-space

  • xsl:output

  • xsl:key

  • xsl:decimal-format

  • xsl:namespace-alias

  • xsl:attribute-set

  • xsl:variable

  • xsl:param

  • xsl:template

An element occurring as a child of an xsl:stylesheet element is called a top-level element.

This example shows the structure of a stylesheet. Ellipses (...) indicate where attribute values or content have been omitted. Although this example shows one of each type of allowed element, stylesheets may contain zero or more of each of these elements.

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="..."/>

  <xsl:include href="..."/>

  <xsl:strip-space elements="..."/>
  
  <xsl:preserve-space elements="..."/>

  <xsl:output method="..."/>

  <xsl:key name="..." match="..." use="..."/>

  <xsl:decimal-format name="..."/>

  <xsl:namespace-alias stylesheet-prefix="..." result-prefix="..."/>

  <xsl:attribute-set name="...">
    ...
  </xsl:attribute-set>

  <xsl:variable name="...">...</xsl:variable>

  <xsl:param name="...">...</xsl:param>

  <xsl:template match="...">
    ...
  </xsl:template>

  <xsl:template name="...">
    ...
  </xsl:template>

</xsl:stylesheet>

The order in which the children of the xsl:stylesheet element occur is not significant except for xsl:import elements and for error recovery. Users are free to order the elements as they prefer, and stylesheet creation tools need not provide control over the order in which the elements occur.

In addition, the xsl:stylesheet element may contain any element not from the XSLT namespace, provided that the expanded-name of the element has a non-null namespace URI. The presence of such top-level elements must not change the behavior of XSLT elements and functions defined in this document; for example, it would not be permitted for such a top-level element to specify that xsl:apply-templates was to use different rules to resolve conflicts. Thus, an XSLT processor is always free to ignore such top-level elements, and must ignore a top-level element without giving an error if it does not recognize the namespace URI. Such elements can provide, for example,

  • information used by extension elements or extension functions (see [Extensions]),

  • information about what to do with the result tree,

  • information about how to obtain the source tree,

  • metadata about the stylesheet,

  • structured documentation for the stylesheet.