2007-01-23
XSL Transformations (XSLT) 2.0
http://www.w3.org/TR/2007/REC-xslt20-20070123/
Kay
Michael
stylesheet
A transformation in the XSLT language is expressed in the form of a stylesheet, whose syntax is well-formed XML conforming to the Namespaces in XML Recommendation .
principal stylesheet module
A stylesheet may consist of several stylesheet modules, contained in different XML documents. For a given transformation, one of these functions as the principal stylesheet module. The complete stylesheet is assembled by finding the stylesheet modules referenced directly or indirectly from the principal stylesheet module using xsl:include and xsl:import elements: see and .
processor
The software responsible for transforming source trees into result trees using an XSLT stylesheet is referred to as the processor. This is sometimes expanded to XSLT processor to avoid any confusion with other processors, for example an XML processor.
implementation
A specific product that performs the functions of an XSLT processor is referred to as an implementation
result tree
The term result tree is used to refer to any tree constructed by instructions in the stylesheet. A result tree is either a final result tree or a temporary tree.
final result tree
A final result tree is a result tree that forms part of the final output of a transformation. Once created, the contents of a final result tree are not accessible within the stylesheet itself.
source tree
The term source tree means any tree provided as input to the transformation. This includes the document containing the initial context node if any, documents containing nodes supplied as the values of stylesheet parameters, documents obtained from the results of functions such as document, doc, and collection, and documents returned by extension functions or extension instructions. In the context of a particular XSLT instruction, the term source tree means any tree provided as input to that instruction; this may be a source tree of the transformation as a whole, or it may be a temporary tree produced during the course of the transformation.
temporary tree
The term temporary tree means any tree that is neither a source tree nor a final result tree.
implementation-defined
In this specification, the term implementation-defined refers to a feature where the implementation is allowed some flexibility, and where the choices made by the implementation must be described in documentation that accompanies any conformance claim.
implementation-dependent
The term implementation-dependent refers to a feature where the behavior may vary from one implementation to another, and where the vendor is not expected to provide a full specification of the behavior.
atomization
The term atomization is defined in . It is a process that takes as input a sequence of nodes and atomic values, and returns a sequence of atomic values, in which the nodes are replaced by their typed values as defined in .
typed value
The term typed value is defined in . Every node except an element defined in the schema with element-only content has a typed value. For example, the typed value of an attribute of type xs:IDREFS is a sequence of zero or more xs:IDREF values.
string value
The term string value is defined in . Every node has a string value. For example, the string value of an element is the concatenation of the string values of all its descendant text nodes.
xPath 1.0 compatibility mode
The term XPath 1.0 compatibility mode is defined in . This is a setting in the static context of an XPath expression; it has two values, true and false. When the value is set to true, the semantics of function calls and certain other operations are adjusted to give a greater degree of backwards compatibility between XPath 2.0 and XPath 1.0.
core function
The term core function means a function that is specified in and that is in the standard function namespace.
XSLT element
An XSLT element is an element in the XSLT namespace whose syntax and semantics are defined in this specification.
deprecated
Some constructs defined in this specification are described as being deprecated. The use of this term implies that stylesheet authors should not use the construct, and that the construct may be removed in a later version of this specification.
initial context node
A node that acts as the initial context node for the transformation. This node is accessible within the stylesheet as the initial value of the XPath expressions. (dot) and self::node(), as described in
base output URI
The base output URI is a URI to be used as the base URI when resolving a relative URI allocated to a final result tree. If the transformation generates more than one final result tree, then typically each one will be allocated a URI relative to this base URI.
initial template
The transformation is performed by evaluating an initial template. If a named template is supplied when the transformation is initiated, then this is the initial template; otherwise, the initial template is the template rule selected according to the rules of the xsl:apply-templates instruction for processing the initial context node in the initial mode.
template rules
A stylesheet contains a set of template rules (see ). A template rule has three parts: a pattern that is matched against nodes, a (possibly empty) set of template parameters, and a sequence constructor that is evaluated to produce a sequence of items.
instruction
An instruction is either an XSLT instruction or an extension instruction.
XSLT instruction
An XSLT instruction is an XSLT element whose syntax summary in this specification contains the annotation <!-- category: instruction -->.
serialization
A frequent requirement is to output a final result tree as an XML document (or in other formats such as HTML). This process is referred to as serialization.
schema components
Type definitions and element and attribute declarations are referred to collectively as schema components.
in-scope schema components
The schema components that may be referenced by name in a stylesheet are referred to as the in-scope schema components. This set is the same throughout all the modules of a stylesheet.
static error
An error that is detected by examining a stylesheet before execution starts (that is, before the source document and values of stylesheet parameters are available) is referred to as a static error.
dynamic error
An error that is not detected until a source document is being transformed is referred to as a dynamic error.
recoverable errors
Some dynamic errors are classed as recoverable errors. When a recoverable error occurs, this specification allows the processor either to signal the error (by reporting the error condition and terminating execution) or to take a defined recovery action and continue processing.
optional recovery action
If an implementation chooses to recover from a recoverable dynamic error, it must take the optional recovery action defined for that error condition in this specification.
non-recoverable dynamic error
A dynamic error that is not recoverable is referred to as a non-recoverable dynamic error. When a non-recoverable dynamic error occurs, the processormust signal the error, and the transformation fails.
type errors
Certain errors are classified as type errors. A type error occurs when the value supplied as input to an operation is of the wrong type for that operation, for example when an integer is supplied to an operation that expects a node.
serialization error
If a transformation has successfully produced a final result tree, it is still possible that errors may occur in serializing the result tree. For example, it may be impossible to serialize the result tree using the encoding selected by the user. Such an error is referred to as a serialization error.
stylesheet modules
A stylesheet consists of one or more stylesheet modules, each one forming all or part of an XML document.
standard stylesheet module
A standard stylesheet module is a tree, or part of a tree, consisting of an xsl:stylesheet or xsl:transform element (see ) together with its descendant nodes and associated attributes and namespaces.
simplified stylesheet module
A simplified stylesheet module is a tree, or part of a tree, consisting of a literal result element together with its descendant nodes and associated attributes and namespaces. This element is not itself in the XSLT namespace, but it must have an xsl:version attribute, which implies that it must have a namespace node that declares a binding for the XSLT namespace. For further details see .
standalone stylesheet module
A standalone stylesheet module is a stylesheet module that comprises the whole of an XML document.
embedded stylesheet module
An embedded stylesheet module is a stylesheet module that is embedded within another XML document, typically the source document that is being transformed.
XSLT namespace
The XSLT namespace has the URI http://www.w3.org/1999/XSL/Transform. It is used to identify elements, attributes, and other names that have a special meaning defined in this specification.
reserved namespaces
The XSLT namespace, together with certain other namespaces recognized by an XSLT processor, are classified as reserved namespaces and must be used only as specified in this and related specifications.
standard function namespace
The standard function namespacehttp://www.w3.org/2005/xpath-functions is used for functions in the function library defined in and standard functions defined in this specification.
XML namespace
The XML namespace, defined in as http://www.w3.org/XML/1998/namespace, is used for attributes such as xml:lang, xml:space, and xml:id.
schema namespace
The schema namespacehttp://www.w3.org/2001/XMLSchema is used as defined in
schema instance namespace
The schema instance namespacehttp://www.w3.org/2001/XMLSchema-instance is used as defined in
extension attributes
An element from the XSLT namespace may have any attribute not from the XSLT namespace, provided that the expanded-QName (see ) of the attribute has a non-null namespace URI. These attributes are referred to as extension attributes.
standard attributes
There are a number of standard attributes that may appear on any XSLT element: specifically version, exclude-result-prefixes, extension-element-prefixes, xpath-default-namespace, default-collation, and use-when.
top-level
An element occurring as a child of an xsl:stylesheet element is called a top-level element.
declarations
Top-level elements fall into two categories: declarations, and user-defined data elements. Top-level elements whose names are in the XSLT namespace are declarations. Top-level elements in any other namespace are user-defined data elements (see )
user-defined data elements
In addition to declarations, the xsl:stylesheet element may contain any element not from the XSLT namespace, provided that the expanded-QName of the element has a non-null namespace URI. Such elements are referred to as user-defined data elements.
forwards-compatible behavior
An element enables forwards-compatible behavior for itself, its attributes, its descendants and their attributes if it has an [xsl:]version attribute (see ) whose value is greater than 2.0.
stylesheet level
A stylesheet level is a collection of stylesheet modules connected using xsl:include declarations: specifically, two stylesheet modules A and B are part of the same stylesheet level if one of them includes the other by means of an xsl:include declaration, or if there is a third stylesheet module C that is in the same stylesheet level as both A and B.
declaration order
The declarations within a stylesheet level have a total ordering known as declaration order. The order of declarations within a stylesheet level is the same as the document order that would result if each stylesheet module were inserted textually in place of the xsl:include element that references it.
import tree
The stylesheet levels making up a stylesheet are treated as forming an import tree. In the import tree, each stylesheet level has one child for each xsl:import declaration that it contains.
import precedence
A declarationD in the stylesheet is defined to have lower import precedence than another declaration E if the stylesheet level containing D would be visited before the stylesheet level containing E in a post-order traversal of the import tree (that is, a traversal of the import tree in which a stylesheet level is visited after its children). Two declarations within the same stylesheet level have the same import precedence.
whitespace text node
A whitespace text node is a text node whose content consists entirely of whitespace characters (that is, #x09, #x0A, #x0D, or #x20).
type annotation
The term type annotation is used in this specification to refer to the value returned by the dm:type-name accessor of a node: see .
qName
A QName is always written in the form (NCName ":")? NCName, that is, a local name optionally preceded by a namespace prefix. When two QNames are compared, however, they are considered equal if the corresponding expanded-QNames are the same, as described below.
lexical qName
A lexical QName is a string representing a QName in the form (NCName ":")? NCName, that is, a local name optionally preceded by a namespace prefix.
defining element
A string in the form of a lexical QName may occur as the value of an attribute node in a stylesheet module, or within an XPath expression contained in such an attribute node, or as the result of evaluating an XPath expression contained in such an attribute node. The element containing this attribute node is referred to as the defining element of the QName.
expanded-QName
An expanded-QNamecontains a pair of values, namely a local name and an optional namespace URI. It may also contain a namespace prefix. Two expanded-QNames are equal if the namespace URIs are the same (or both absent) and the local names are the same. The prefix plays no part in the comparison, but is used only if the expanded-QName needs to be converted back to a string.
xPath expression
Within this specification, the term XPath expression, or simply expression, means a string that matches the production Expr defined in .
required type
The context within a stylesheet where an XPath expressionappears may specify the required type of the expression. The required type indicates the type of the value that the expression is expected to return.
function conversion rules
Except where otherwise indicated, the actual value of an expression is converted to the required type using the function conversion rules. These are the rules defined in for converting the supplied argument of a function call to the required type of that argument, as defined in the function signature. The relevant rules are those that apply when XPath 1.0 compatibility mode is set to false.
default collation
In this specification the term default collation means the collation that is used by XPath operators such as eq and lt appearing in XPath expressions within the stylesheet.
focus
When a sequence constructor is evaluated, the processor keeps track of which items are being processed by means of a set of implicit variables referred to collectively as the focus.
context item
The context item is the item currently being processed. An item (see ) is either an atomic value (such as an integer, date, or string), or a node. The context item is initially set to the initial context node supplied when the transformation is invoked (see ). It changes whenever instructions such as xsl:apply-templates and xsl:for-each are used to process a sequence of items; each item in such a sequence becomes the context item while that item is being processed.
context position
The context position is the position of the context item within the sequence of items currently being processed. It changes whenever the context item changes. When an instruction such as xsl:apply-templates or xsl:for-each is used to process a sequence of items, the first item in the sequence is processed with a context position of 1, the second item with a context position of 2, and so on.
context size
The context size is the number of items in the sequence of items currently being processed. It changes whenever instructions such as xsl:apply-templates and xsl:for-each are used to process a sequence of items; during the processing of each one of those items, the context size is set to the count of the number of items in the sequence (or equivalently, the position of the last item in the sequence).
context node
If the context item is a node (as distinct from an atomic value such as an integer), then it is also referred to as the context node. The context node is not an independent variable, it changes whenever the context item changes. When the context item is an atomic value, there is no context node.
singleton focus
A singleton focus based on a node N has the context item (and therefore the context node) set to N, and the context position and context size both set to 1 (one).
pattern
A pattern specifies a set of conditions on a node. A node that satisfies the conditions matches the pattern; a node that does not satisfy the conditions does not match the pattern. The syntax for patterns is a subset of the syntax for expressions.
attribute value template
In an attribute that is designated as an attribute value template, such as an attribute of a literal result element, an expression can be used by surrounding the expression with curly brackets ({})
effective value
The result of evaluating an attribute value template is referred to as the effective value of the attribute.
sequence constructor
A sequence constructor is a sequence of zero or more sibling nodes in the stylesheet that can be evaluated to return a sequence of nodes and atomic values. The way that the resulting sequence is used depends on the containing instruction.
namespace fixup
The rules for the individual XSLT instructions that construct a result tree (see ) prescribe some of the situations in which namespace nodes are written to the tree. These rules, however, are not sufficient to ensure that the prescribed constraints are always satisfied. The XSLT processor must therefore add additional namespace nodes to satisfy these constraints. This process is referred to as namespace fixup.
URI reference
Within this specification, the term URI Reference, unless otherwise stated, refers to a string in the lexical space of the xs:anyURI data type as defined in .
template
An xsl:template declaration defines a template, which contains a sequence constructor for creating nodes and/or atomic values. A template can serve either as a template rule, invoked by matching nodes against a pattern, or as a named template, invoked explicitly by name. It is also possible for the same template to serve in both capacities.
default priority
If no priority attribute is specified on the xsl:template element, a default priority is computed, based on the syntax of the pattern supplied in the match attribute.
modes
Modes allow a node in a source tree to be processed multiple times, each time producing a different result. They also allow different sets of template rules to be active when processing different trees, for example when processing documents loaded using the document function (see ) or when processing temporary trees.
default mode
There is always a default mode available. The default mode is an unnamed mode, and it is used when no mode attribute is specified on an xsl:apply-templates instruction.
current mode
At any point in the processing of a stylesheet, there is a current mode. When the transformation is initiated, the current mode is the default mode, unless a different initial mode has been supplied, as described in . Whenever an xsl:apply-templates instruction is evaluated, the current mode becomes the mode selected by this instruction.
current template rule
At any point in the processing of a stylesheet, there may be a current template rule. Whenever a template rule is chosen as a result of evaluating xsl:apply-templates, xsl:apply-imports, or xsl:next-match, the template rule becomes the current template rule for the evaluation of the rule's sequence constructor. When an xsl:for-each, xsl:for-each-group, or xsl:analyze-string instruction is evaluated, or when evaluating a sequence constructor contained in an xsl:sort or xsl:key element, or when a stylesheet function is called (see ), the current template rule becomes null for the evaluation of that instruction or function.
variable-binding elements
The two elements xsl:variable and xsl:param are referred to as variable-binding elements
variable
The xsl:variable element declares a variable, which may be a global variable or a local variable.
parameter
The xsl:param element declares a parameter, which may be a stylesheet parameter, a template parameter, or a function parameter. A parameter is a variable with the additional property that its value can be set by the caller when the stylesheet, the template, or the function is invoked.
value
A variable is a binding between a name and a value. The value of a variable is any sequence (of nodes and/or atomic values), as defined in .
supplied value
The value of the variable is computed using the expression given in the select attribute or the contained sequence constructor, as described in . This value is referred to as the supplied value of the variable.
global variable
A top-level variable-binding element declares a global variable that is visible everywhere (except where it is shadowed by another binding).
stylesheet parameter
A top-level xsl:param element declares a stylesheet parameter. A stylesheet parameter is a global variable with the additional property that its value can be supplied by the caller when a transformation is initiated.
local variable
As well as being allowed as declaration elements, the xsl:variable element is also allowed in sequence constructors. Such a variable is known as a local variable.
template parameter
An xsl:param element may appear as a child of an xsl:template element, before any non-xsl:param children of that element. Such a parameter is known as a template parameter. A template parameter is a local variable with the additional property that its value can be set when the template is called, using any of the instructions xsl:call-template, xsl:apply-templates, xsl:apply-imports, or xsl:next-match.
function parameter
An xsl:param element may appear as a child of an xsl:function element, before any non-xsl:param children of that element. Such a parameter is known as a function parameter. A function parameter is a local variable with the additional property that its value can be set when the function is called, using a function call in an XPath expression.
shadows
A binding shadows another binding if the binding occurs at a point where the other binding is visible, and the bindings have the same name.
circularity
A circularity is said to exist if a construct such as a global variable, an attribute set, or a key is defined in terms of itself. For example, if the expression or sequence constructor specifying the value of a global variableX references a global variable Y, then the value for Ymust be computed before the value of X. A circularity exists if it is impossible to do this for all global variable definitions.
named template
Templates can be invoked by name. An xsl:template element with a name attribute defines a named template.
tunnel parameter
A parameter passed to a template may be defined as a tunnel parameter. Tunnel parameters have the property that they are automatically passed on by the called template to any further templates that it calls, and so on recursively.
attribute set
The xsl:attribute-set element defines a named attribute set: that is, a collection of attribute definitions that can be used repeatedly on different constructed elements.
font-family
is specified only in the attribute set
font-size
is specified in the attribute set, is specified on the literal result element, and in an xsl:attribute instruction
font-style
is specified in the attribute set, and on the literal result element
font-weight
is specified in the attribute set, and in an xsl:attribute instruction
stylesheet function
An xsl:function declaration declares the name, parameters, and implementation of a stylesheet function that can be called from any XPath expression within the stylesheet.
arity
The arity of a stylesheet function is the number of xsl:param elements in the function definition.
literal result element
In a sequence constructor, an element in the stylesheet that does not belong to the XSLT namespace and that is not an extension instruction (see ) is classified as a literal result element.
literal namespace URI
A namespace URI in the stylesheet tree that is being used to specify a namespace URI in the result tree is called a literal namespace URI.
target namespace URI
The namespace URI that is to be used in the result tree as a substitute for a literal namespace URI is called the target namespace URI.
alias
A stylesheet can use the xsl:namespace-alias element to declare that a literal namespace URI is being used as an alias for a target namespace URI.
place marker
The xsl:number instruction performs two tasks: firstly, determining a place marker (this is a sequence of integers, to allow for hierarchic numbering schemes such as 1.12.2 or 3(c)ii), and secondly, formatting the place marker for output as a text node in the result sequence.
sort key specification
A sort key specification is a sequence of one or more adjacent xsl:sort elements which together define rules for sorting the items in an input sequence to form a sorted sequence.
sort key component
Within a sort key specification, each xsl:sort element defines one sort key component.
stable
A sort key specification is said to be stable if its first xsl:sort element has no stable attribute, or has a stable attribute whose effective value is yes.
initial sequence
The sequence to be sorted is referred to as the initial sequence.
sorted sequence
The sequence after sorting as defined by the xsl:sort elements is referred to as the sorted sequence.
sort key value
For each item in the initial sequence, a value is computed for each sort key component within the sort key specification. The value computed for an item by using the Nth sort key component is referred to as the Nth sort key value of that item.
collation
Facilities in XSLT 2.0 and XPath 2.0 that require strings to be ordered rely on the concept of a named collation. A collation is a set of rules that determine whether two strings are equal, and if not, which of them is to be sorted before the other.
current group
The evaluation context for XPath expressions includes a component called the current group, which is a sequence. The current group is the collection of related items that are processed collectively in one iteration of the xsl:for-each-group element.
current grouping key
The evaluation context for XPath expressions includes a component called the current grouping key, which is an atomic value. The current grouping key is the grouping key shared in common by all the items within the current group.
groups
The xsl:for-each-group instruction allocates the items in an input sequence into groups of items (that is, it establishes a collection of sequences) based either on common values of a grouping key, or on a pattern that the initial or final node in a group must match.
population
The sequence of items to be grouped, which is referred to as the population, is determined by evaluating the XPath expression contained in the select attribute.
population order
The population is treated as a sequence; the order of items in this sequence is referred to as population order
grouping keys
If either of the group-by attribute or group-adjacent attributes is present, then grouping keys are calculated for each item in the population. The grouping keys are the items in the sequence obtained by evaluating the expression contained in the group-by attribute or group-adjacent attribute, atomizing the result, and then casting an xs:untypedAtomic value to xs:string.
initial item
For each group, the item within the group that is first in population order is known as the initial item of the group.
order of first appearance
There is an ordering among groups referred to as the order of first appearance. A group G is defined to precede a group H in order of first appearance if the initial item of G precedes the initial item of H in population order. If two groups G and H have the same initial item (because the item is in both groups) then G precedes H if the grouping key of G precedes the grouping key of H in the sequence that results from evaluating the group-by expression of this initial item.
processing order
There is another ordering among groups referred to as processing order. If group R precedes group S in processing order, then in the result sequence returned by the xsl:for-each-group instruction the items generated by processing group R will precede the items generated by processing group S.
current captured substrings
While the xsl:matching-substring instruction is active, a set of current captured substrings is available, corresponding to the parenthesized sub-expressions of the regular expression.
key
A key is defined as a set of xsl:key declarations in the stylesheet that share the same name.
key specifier
The expression in the use attribute and the sequence constructor within an xsl:key declaration are referred to collectively as the key specifier. The key specifier determines the values that may be used to find a node using this key.
decimal format
All the xsl:decimal-format declarations in a stylesheet that share the same name are grouped into a named decimal format; those that have no name are grouped into a single unnamed decimal format.
picture string
The formatting of a number is controlled by a picture string. The picture string is a sequence of characters, in which the characters assigned to the variables decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign and pattern-separator-sign are classified as active characters, and all other characters (including the percent-sign and per-mille-sign) are classified as passive characters.
date formatting functions
The three functions format-date, format-time, and format-dateTime are referred to collectively as the date formatting functions.
extension instruction
An extension instruction is an element within a sequence constructor that is in a namespace (not the XSLT namespace) designated as an extension namespace.
extension function
An extension function is a function that is available for use within an XPath expression, other than a core function defined in , an additional function defined in this XSLT specification, a constructor function named after an atomic type, or a stylesheet function defined using an xsl:function declaration.
extension namespaces
The extension instruction mechanism allows namespaces to be designated as extension namespaces. When a namespace is designated as an extension namespace and an element with a name from that namespace occurs in a sequence constructor, then the element is treated as an instruction rather than as a literal result element.
output states
Each instruction in the stylesheet is evaluated in one of two possible output states: final output state or temporary output state
final output
The first of the two output states is called final output state. This state applies when instructions are writing to a final result tree.
temporary output
The second of the two output states is called temporary output state. This state applies when instructions are writing to a temporary tree or any other non-final destination.
output definition
All the xsl:output declarations in a stylesheet that share the same name are grouped into a named output definition; those that have no name are grouped into a single unnamed output definition.
character map
A character map allows a specific character appearing in a text or attribute node in the final result tree to be substituted by a specified string of characters during serialization.
basic XSLT processor
A basic XSLT processor is an XSLT processor that implements all the mandatory requirements of this specification with the exception of certain explicitly-identified constructs related to schema processing.
schema-aware XSLT processor
A schema-aware XSLT processor is an XSLT processor that implements all the mandatory requirements of this specification, including those features that a basic XSLT processor signals as an error. The mandatory requirements of this specification are taken to include the mandatory requirements of XPath 2.0, as described in . A requirement is mandatory unless the specification includes wording (such as the use of the words should or may) that clearly indicates that it is optional.
serialization feature
A processor that claims conformance with the serialization featuremust support the conversion of a final result tree to a sequence of octets following the rules defined in .
backwards compatibility feature
A processor that claims conformance with the backwards compatibility featuremust support the processing of stylesheet instructions and XPath expressions with backwards compatible behavior, as defined in .