7.4 The stylesheet Element

As mentioned before, XSLT is an XML application, so stylesheets are XML documents. The document element is stylesheet, although you are also allowed to use transform if the term stylesheet bugs you. This element is where you must declare the XSLT's namespace and version. The namespace identifier is http://www.w3.org/1999/XSL/Transform/. Both the namespace and version attributes are required.

XSLT can be extended by the implementer to perform special functions not contained in the specification. For example, you can add a feature to redirect output to multiple files. These extensions are identified by a separate namespace that you must declare if you want to use them. And, just to make things clear for the XSLT engine, you should set the attribute extension-element-prefixes to contain the namespace prefixes of extensions.

As an example, consider the stylesheet element below. It declares namespaces for XSLT control elements (prefix xsl) and implementation-specific elements (prefix ext). Finally, it specifies the version 1.0 of XSLT in the last attribute.


The namespace, represented here as xsl is used by the transformation processor to determine which elements control the process. Any elements or attributes not in that namespace nor the extensions namespace will be interpreted as data to be output in the result tree.