XML technologies / XSLT / Reference: XSLT 1.0 and 2.0 elements / Brief overview of XSLT 1.0
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 6.)
Element overview
XSLT 1.0 has 35 elements:
Two root elements:
xsl:stylesheet, xsl:transform
Twelve top-level elements:
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
Seventeen instructions:
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:processing-instruction, xsl:text, xsl:value-of,
Four sub-instructions:
xsl:otherwise, xsl:sort, xsl:when, xsl:with-param
This diagram shows the XSLT 1.0 element hierarchy.
Figure: XSLT 1.0 element overview.
Standard attributes in XSLT 1.0
Every XSLT 1.0 element, and still in 2.0, supports two standard attributes: xml:lang and xml:space. Both belong, under the 1999 W3C recommendation for namespaces, to the fixed namespace. This XML namespace need not be explicitly declared: it applies by definition to every XML document:
xmlns:xml="http://www.w3.org/XML/1998/namespace"
For the prefix xml, this namespace URI is fixed: the prefix cannot bind another namespace. Other prefixes may bind this URI, though that is rarely useful. When using attributes xml, declare them in the DTD or document schema if necessary.
xml:lang
Value | string (country code) |
Usage | Optional, standard attribute |
Introduced | XSLT 1.0 |
Standard attribute xml:lang can appear on any XML element, including XSLT elements, to specify content language. Under RFC 1766, a two-letter country code according to ISO 639 or ISO 3166-1 represents it.
Alternatively, use an IANA code prefixed with i-. User-defined codes are prefixed with x-. A language declaration using xml:lang applies to all content and attribute values unless an enclosed element overrides it through another xml:lang declaration.
xml:space
Value | "default" (default) | "preserve" |
Usage | Optional, standard attribute |
Introduced | XSLT 1.0 |
Attribute xml:space controls how the XML parser handles whitespace, spaces, tabs and line breaks, in the marked element. The two values are default and preserve. Value preserve preserves all whitespace for the next application.
Without attribute xml:space or with value default, the parser may remove insignificant whitespace. It applies to all content of the element. For normal parsing within a region marked preserve, set xml:space="default" on the enclosed element.
Attribute value templates in XSLT 1.0 instructions
XSLT 1.0 permits attribute value templates, AVTs, only in these five instructions and only for the attributes listed on the right:
XSLT instruction | AVT permitted for attributes |
|---|---|
| |
| |
| |
| |
| |
Table: Attribute value templates allowed in XSLT 1.0 instructions.
What is an attribute value template?
An attribute value template, AVT, lets the XSLT processor evaluate an XPath expression (expression) at runtime as a placeholder for an attribute value in a Literal Result Element or certain XSLT instructions.
AVTs are enclosed in braces, which are not part of the XPath expression being evaluated:
attributname="{expression}"
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from “XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn