The following associated resources are available: Specification in XML format, XSD 1.1 Schema for XSLT 4.0 Stylesheets (non-normative), Relax-NG Schema for XSLT 4.0 Stylesheets (non-normative), Stylesheet for XML-to-JSON conversion (non-normative)
Copyright © 2026 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply.
This specification defines the syntax and semantics of XSLT 4.0, a language designed primarily for transforming XML documents into other XML documents.
XSLT 4.0 is a revised version of the XSLT 3.0 Recommendation [XSLT 3.0] published on 8 June 2017. Changes are presented in 1.2 What’s New in XSLT 4.0?.
XSLT 4.0 is designed to be used in conjunction with XPath 4.0, which is defined in [XPath 4.0]. XSLT shares the same data model as XPath 4.0, which is defined in [XDM 3.0], and it uses the library of functions and operators defined in [Functions and Operators 4.0]. XPath 4.0 and the underlying function library introduce a number of enhancements, for example the availability of union and record types.
This document contains hyperlinks to specific sections or definitions within other documents in this family of specifications. These links are indicated visually by a superscript identifying the target specification: for example XP for XPath 4.0, DM for the XDM data model version 4.0, FO for Functions and Operators version 4.0.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.
This document has no official standing. It is produced by the editor as a proposal for community review. Insofar as it copies large amounts of text from the W3C XSLT 3.0 Recommendation, W3C copyright and similar provisions apply.
The publications of this community group are dedicated to our co-chair, Michael Sperberg-McQueen (1954–2024).
Changes in 4.0 ⬇
Use the arrows to browse significant changes since the 3.0 version of this specification.
Sections with significant changes are marked Δ in the table of contents.
XSLT 4.0 is a revised version of the XSLT 3.0 Recommendation [XSLT 3.0] published on 8 June 2017.
The changes in this version of the language are relatively minor usability enhancements. There are no changes to the data model or processing model. Instead, the specification attempts to fill a number of gaps in functionality resulting from feedback from XSLT 3.0 users. The main areas covered are:
Enhancements to the type system to allow more expressive constraints, especially for maps and atomic values.
Additional functionality for processing arrays.
Exploitation of the power afforded by first-class function items.
XSLT 4.0 also includes optional facilities to serialize the results of a transformation, by means of an interface to the serialization component described in [XSLT and XQuery Serialization 4.0].
XSLT 4.0 requires support for XPath 4.0.
A full list of changes is at JI Changes since XSLT 3.0.
For a full glossary of terms, see CB Glossary.
[Definition: 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.]
[Definition: A specific product that performs the functions of an XSLT processor is referred to as an implementation.]
[Definition: The term tree is used (as in [XDM 3.0]) to refer to the aggregate consisting of a parentless node together with all its descendant nodes, plus all their attributes and namespaces.]
Note:
The use of the term tree in this document in phrases such as source tree, result tree, and temporary tree does not imply the use of a data structure in memory that holds the entire contents of the document at one time. It implies rather a logical view of the XML input and output in which elements have a hierarchic relationship to each other. When a source document is being processed in a streaming manner, access to the nodes in this tree is constrained, but it is still viewed and described as a tree.
The output of a transformation consists of the following:
[Definition: A principal result: this can be any sequence of items (as defined in [XDM 3.0]).] The principal result is the value returned by the function or template in the stylesheet that is nominated as the entry point, as described in 2.3 Initiating a Transformation.
[Definition: Zero or more secondary results: each secondary result can be any sequence of items (as defined in [XDM 3.0]).] A secondary result is the value returned by evaluating the body of an xsl:result-document instruction.
Zero or more messages. Messages are generated by the xsl:message and xsl:assert instructions, and are described in 24.123.1 Messages and 24.223.2 Assertions.
Static or dynamic errors: see 2.14 Error Handling.
The principal result and the secondary results may be post-processed as described in 2.3.6 Post-processing the Raw Result.
[Definition: 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.]
[Definition: A final result tree is a result tree that forms part of the output of a transformation: specifically, a tree built by post-processing the items in the principal result or in a secondary result. Once created, the contents of a final result tree are not accessible within the stylesheet itself.] Any final result tree may be serialized as described in 2726 Serialization.
[Definition: The term source tree means any tree provided as input to the transformation. This includes the document containing the global context item if any, documents containing nodes present in the initial match selection, documents containing nodes supplied as the values of stylesheet parameters, documents obtained from the results of functions such as document, doc, and collection, documents read using the xsl:source-document instruction, 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.]
[Definition: The term temporary tree means any tree that is neither a source tree nor a final result tree.] Temporary trees are used to hold intermediate results during the execution of the transformation.
Unless otherwise stated, the term “tree” refers to a tree rooted at a parentless node: that is, the term does not include subtrees of larger trees. Every node therefore belongs to exactly one tree.
In this specification the phrases must, must not, should, should not, may, required, and recommended, when used in normative text and rendered in small capitals, are to be interpreted as described in [RFC2119].
Where the phrase must, must not, or required relates to the behavior of the XSLT processor, then an implementation is not conformant unless it behaves as specified, subject to the more detailed rules in 2827 Conformance.
Where the phrase must, must not, or required relates to a stylesheet then the processor must enforce this constraint on stylesheets by raising an error if the constraint is not satisfied.
Where the phrase should, should not, or recommended relates to a stylesheet then a processor may produce warning messages if the constraint is not satisfied, but must not treat this as an error.
[Definition: 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.]
[Definition: 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.] (This might apply, for example, to limits on the size of source documents that can be transformed.)
In all cases where this specification leaves the behavior implementation-defined or implementation-dependent, the implementation has the option of providing mechanisms that allow the user to influence the behavior.
A paragraph labeled as a Note or described as an example is non-normative.
Many terms used in this document are defined in the XPath specification [XPath 3.0] or the XDM specification [XDM 3.0]. Particular attention is drawn to the following:
[Definition: The term atomization is defined in Section 2.5.3 AtomizationXP. It is a process that takes as input a sequence of items, and returns a sequence of atomic items, in which the nodes are replaced by their typed values as defined in [XDM 3.0]. Arrays (see 22 Arrays) are atomized by atomizing their members, recursively.] For some items (for example, elements with element-only content, function items, and maps, atomization raises a dynamic error.
[Definition: The term typed value is defined in Section 5.15 typed-value Accessor DM30. Every node, other than an element whose type annotation identifies it as having 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.]
[Definition: The term string value is defined in Section 5.13 string-value Accessor DM30. 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.]
[Definition: The term XPath 1.0 compatibility mode is defined in Section 2.2.1 Static ContextXP. 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 4.0 and XPath 1.0.]
[Definition: The term function definition is defined in Section 2.2.1 Static ContextXP. It is the definition of a function that can be called statically from within an XPath expression: in the case of XSLT it typically means either a stylesheet function, or a built-in function such as those defined in [Functions and Operators 4.0]]
[Definition: A function definition has an arity range, which defines the minimum and maximum number of arguments that must be supplied in a call to the function. The static context can contain multiple function definitions with the same name, provided that their arity ranges do not overlap.]
[Definition: An XSLT element is an element in the XSLT namespace whose syntax and semantics are defined in this specification.] For a non-normative list of XSLT elements, see DC Element Syntax Summary.
In this document the specification of each XSLT element is preceded by a summary of its syntax in the form of a model for elements of that element type. A full list of all these specifications can be found in DC Element Syntax Summary. The meaning of the syntax summary notation is as follows:
An attribute that is required is shown with its name in bold. An attribute that may be omitted is shown with a question mark following its name.
An attribute that is deprecated is shown in a grayed font within square brackets.
The string that occurs in the place of an attribute value specifies the allowed values of the attribute. If this is surrounded by curly brackets ({...}), then the attribute value is treated as an attribute value template, and the string occurring within curly brackets specifies the allowed values of the result of evaluating the attribute value template. Alternative allowed values are separated by |. A quoted string indicates a value equal to that specific string. An unquoted, italicized name specifies a particular type of value.
The types used, and their meanings, are as follows:
booleanOne of the strings "yes", "true", or "1" to indicate the value true, or one of the strings "no", "false", or "0" to indicate the value false. Note: the values are synonyms; where this specification uses a phrase such as “If required='yes' is specified ...” this is to be interpreted as meaning “If the attribute named required is present, and has the value yes, true, or 1 (after stripping leading and trailing whitespace) ...”.
stringAny string.
expressionAn XPath expression.
patternA pattern as described in 5.4 Patterns.
item-typeAn ItemTypeXP as defined in the XPath 4.0 specification.
sequence-typeA SequenceTypeXP as defined in the XPath 4.0 specification.
uri; urisA URI, for example a namespace URI or a collation URI; a whitespace-separated list of URIs.
qnameA lexical QName as defined in 5.1.1 Qualified Names.
eqname; eqnamesAn EQName as defined in 5.1.1 Qualified Names; a whitespace-separated list of EQNames.
token; tokensA string containing no significant whitespace; a whitespace-separated list of such strings.
nmtoken; nmtokensA string conforming to the XML schema rules for the type xs:NMTOKEN; a whitespace-separated list of such strings.
charA string comprising a single Unicode character.
languageA string in the value space of xs:language, or a zero-length string.
integerAn integer, that is, a string that is castable to the schema type xs:integer.
decimalA decimal value, that is, a string that is castable to the schema type xs:decimal.
ncname; ncnamesAn unprefixed name: a string that is castable to the schema type xs:NCName; a whitespace-separated list of such strings.
prefix; prefixesAn xs:NCName representing a namespace prefix, which must be in scope for the element on which it appears; a whitespace-separated list of such strings.
idAn xs:NCName used as a unique identifier for an element in the containing XML document.
Except where the set of allowed values of an attribute is specified using the italicized name string or char, leading and trailing whitespace in the attribute value is ignored. In the case of an attribute value template, this applies to the effective value obtained when the attribute value template is expanded.
XPath comments (delimited by (: ... :)) are permitted anywhere that inter-token whitespace is permitted in attributes whose type is given as expression, pattern, item-type, or sequence-type, and are not permitted in attributes of other types (other than within expressions enclosed by curly braces within an attribute value template).
If an attribute has a simple default value, this is shown between tortoise-shell brackets (for example 〔'no'〕). Where no default is shown, the consequence of omitting the attribute is explained in the prose narrative. Default values shown in the summary apply only where the attribute itself is applicable; if an attribute is not permitted to appear in the particular context, then its default value should be ignored. (For example, the stable attribute of xsl:sort is shown as having a default value of 'yes', but the attribute is allowed only on the first of a sequence of adjacent xsl:sort elements.) The quotation marks around a default value are not part of the value.
Unless the element is required to be empty, the model element contains a comment specifying the allowed content. The allowed content is specified in a way similar to an element type declaration in XML; sequence constructor means that any mixture of text nodes, literal result elements, extension instructions, and XSLT elements from the instruction category is allowed; other-declarations means that any mixture of XSLT elements from the declaration category is allowed, together with user-defined data elements.
The element is prefaced by comments indicating if it belongs to the instruction category or declaration category or both. The category of an element affects only whether it is allowed in the content of elements that allow a sequence constructor or other-declarations.
This example illustrates the notation used to describe XSLT elements.
<!-- Category: instruction -->
<xsl:example-element
select = expression
debug? = boolean
validation? = { "strict" | "lax" }〔strict〕 >
<!-- Content: ((xsl:variable | xsl:param)*, xsl:sequence) -->
</xsl:example-element>
This example defines a (non-existent) element xsl:example-element. The element is classified as an instruction. It takes the following attributes:
A mandatory select attribute, whose value is an XPath expression
An optional debug attribute, whose value must be yes, true, or 1 to indicate true, or no, false, or 0 to indicate false.
An optional validation attribute, whose value must be strict or lax; the curly brackets indicate that the value can be defined as an attribute value template, allowing a value such as validation="{ $val }", where the variableval is evaluated to yield "strict" or "lax" at run-time. The value strict in tortoise-shell brackets indicates the default value, if the attribute is not present.
The content of an xsl:example-element instruction is defined to be a sequence of zero or more xsl:variable and xsl:param elements, followed by an xsl:sequence element.
[ERR XTSE0010] It is a static error if an XSLT-defined element is used in a context where it is not permitted, if a required attribute is omitted, or if the content of the element does not correspond to the content that is allowed for the element.
The rules in the element syntax summary (both for the element structure and for its attributes) apply to the stylesheet content after preprocessing as described in 3.13 Stylesheet Preprocessing.
[Definition: The effective value of an attribute or text node in the stylesheet is the value after any required expansion or normalization.]
More specifically, the effective value is the value after:
Expanding shadow attributes as described in 3.13.4 Shadow Attributes;
Expanding defaults (for example, if an xsl:message instruction has no terminate attribute, then the effective value of the terminate attribute is no);
Stripping ignored whitespace (for example, the effective value of a boolean attribute written as terminate=" no " is no);
Replacing synonyms (for example in boolean attributes, 1 and true are synonyms of yes);
Expanding attribute value templates and text value templates.
Applying rules from the static context: for example, the effective value of a collation attribute is the value after expanding a relative URI against the static base URI.
Attributes are validated as follows. These rules apply to the value of the attribute after removing leading and trailing whitespace.
[ERR XTSE0020] It is a static error if an attribute (other than an attribute written using curly brackets in a position where an attribute value template is permitted) contains a value that is not one of the permitted values for that attribute.
[ERR XTDE0030] It is a dynamic error if the effective value of an attribute written using curly brackets, in a position where an attribute value template is permitted, is a value that is not one of the permitted values for that attribute. If the processor is able to detect the error statically (for example, when any XPath expressions within the curly brackets can be evaluated statically), then the processor may optionally raise this as a static error.
Special rules apply if the construct appears in part of the stylesheet that is processed with forwards compatible behavior: see 3.10 Forwards Compatible Processing.
[Definition: 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.]
Note:
This specification includes a non-normative XML Schema for XSLT stylesheet modules (see IH Schemas for XSLT 4.0 Stylesheets). The syntax summaries described in this section are normative.
XSLT defines a set of standard functions which are additional to those defined in [Functions and Operators 4.0]. A list of these functions appears in HG.2 List of XSLT-defined functions. The signatures of these functions are described using the same notation as used in [Functions and Operators 4.0]. The names of many of these functions are in the standard function namespace.
This document does not specify any application programming interfaces or other interfaces for initiating a transformation. This section, however, describes the information that is supplied when a transformation is initiated. Except where otherwise indicated, the information is required.
The execution of a stylesheet necessarily involves two activities: static analysis and dynamic evaluation. Static analysis consists of those tasks that can be performed by inspection of the stylesheet alone, including the binding of static variables, the evaluation of [xsl:]use-when expressions (see 3.13.3 Conditional Element Inclusion) and shadow attributes (see 3.13.4 Shadow Attributes), and the detection of static errors. Dynamic evaluation consists of tasks which in general cannot be carried out until a source document is available.
Dynamic evaluation is further divided into two activities: priming the stylesheet, and invoking a selected component.
Priming the stylesheet provides the dynamic context for evaluation, and supplies all the information needed to establish the values of global variables.
Invoking a component (such as a template or function) causes evaluation of that template or function to produce a result, which is an arbitrary XDM value.
[Definition: The result of invoking the selected component, after any required conversion to the declared result type of the component, is referred to as the raw result.]
The raw result of the invocation is the immediate result of evaluating the sequence constructor contained in the target template or function, modified by applying the coercion rules to convert the immediate result to the type declared in the as attribute of the xsl:template or xsl:function declaration, if present.
This raw result may optionally be post-processed to construct a result tree, to serialize the result, or both, as described in 2.3.6 Post-processing the Raw Result.
Implementations may allow static analysis and dynamic evaluation to be initiated independently, so that the cost of static analysis can be amortized over multiple transformations using the same stylesheet. Implementations may also allow priming of a stylesheet and invocation of components to be initiated independently, in which case a single act of priming the stylesheet may be followed by a series of independent component invocations. Although this specification does not require such a separation, this section distinguishes information that is needed before static analysis can proceed, information that is needed to prime the stylesheet, and information that is needed when invoking components.
The language is designed to allow the static analysis of each package to be performed independently of other packages, with only basic knowledge of the properties of components made available by used packages. Beyond this, the specification leaves it to implementations to decide how to organize this process. When packages are not used explicitly, the entire stylesheet is treated as a single package.
[Definition: A stylesheet may be evaluated by supplying a value to be processed, together with an initial mode. The value (which can be any sequence of items) is referred to as the initial match selection. The processing then corresponds to the effect of the xsl:apply-templates instruction.]
The initial match selection will often be a single document node, traditionally called the source document of the transformation; but in general, it can be any sequence. If the initial match selection is an empty sequence, the result of the transformation will be empty, since no template rules are evaluated.
Processing proceeds by finding the template rules that match the items in the initial match selection, and evaluating these template rules with a focus based on the initial match selection. The template rules are evaluated in final output state.
The following information is needed when dynamic evaluation is to start with a template rule:
The initial match selection. An API that chooses to maintain compatibility with previous versions of this specification should allow a method of invocation in which a singleton node is provided, which is then used in two ways: the node itself acts as the initial match selection, and the root node of the containing tree acts as the global context item.
Optionally, an initial mode.
[Definition: The initial mode is the mode used to select template rules for processing items in the initial match selection when apply-templates invocation is used to initiate a transformation.]
In searching for the template rule that best matches the items in the initial match selection, the processor considers only those rules that apply to the initial mode.
If no initial mode is supplied explicitly, then the initial mode is that named in the default-mode attribute of the (explicit or implicit) xsl:package element of the top-level package or in the absence of such an attribute, the unnamed mode.
[ERR XTDE0044] It is a dynamic error if the invocation of the stylesheet specifies an initial mode when no initial match selection is supplied (either explicitly, or defaulted to the global context item).
A (named or unnamed) modeM is eligible as an initial mode if one of the following conditions applies, where P is the top-level package of the stylesheet:
M is explicitly declared in an xsl:mode declaration within P, and has public or finalvisibility (either by virtue of its visibility attribute, or by virtue of an xsl:expose declaration).
M is the unnamed mode.
M is named in the default-mode attribute of the (explicit or implicit) xsl:package element of P.
M is declared in a package used by P, and is given public or finalvisibility in P by means of an xsl:accept declaration.
The effective value of the declared-modes attribute of the explicit or implicit xsl:package element of P is no, and M appears as a mode-name in the mode attribute of a template rule declared within P.
[ERR XTDE0045] It is a dynamic error if the invocation of the stylesheet specifies an initial mode and the specified mode is not eligible as an initial mode (as defined above).
Parameters, which will be passed to the template rules used to process items in the input sequence. The parameters consist of two sets of (QName, value) pairs, one set for tunnel parameters and one for non-tunnel parameters, in which the QName identifies the name of a parameter and the value provides the value of the parameter. Either or both sets of parameters may be empty. The effect is the same as when a template is invoked using xsl:apply-templates with an xsl:with-param child specifying tunnel="yes" or tunnel="no" as appropriate. If a parameter is supplied that is not declared or used, the value is simply ignored. These parameters are not used to set stylesheet parameters.
A supplied value is converted if necessary to the declared type of the template parameter using the coercion rules.
Details of how the result of the initial template is to be returned. For details, see 2.3.6 Post-processing the Raw Result
The raw result of the invocation is the result of processing the supplied input sequence as if by a call on xsl:apply-templates in the specified mode: specifically, each item in the input sequence is processed by selecting and evaluating the best matching template rule, and converting the result (if necessary) to the type declared in the as attribute of that template using the coercion rules; and the results of processing each item are then concatenated into a single sequence, respecting the order of items in the input sequence.
Note:
If the initial mode is declared-streamable, then a streaming processor should allow some or all of the items in the initial match selection to be nodes supplied in streamable form, and any nodes that are supplied in this form must then be processed using streaming.
Since the global context item cannot be a streamed node, in cases where the transformation is to proceed by applying streamable templates to a streamed input document, the global context item must either be absent, or must be something that differs from the initial match selection.
Note:
The design of the API for invoking a transformation should provide some means for users to designate the unnamed mode as the initial mode in cases where it is not the default mode.
It is a dynamic error[see ERR XTDE0700] if the template rule selected for processing any item in the initial match selection defines a template parameter that specifies required="yes" and no value is supplied for that parameter.
Note:
A stylesheet can process further source documents in addition to those supplied when the transformation is invoked. These additional documents can be loaded using the functions document (see 20.1 fn:document); or doc, unparsed-text, unparsed-text-lines, or collection (see [Functions and Operators 4.0]); or using the xsl:source-document instruction; alternatively, they can be supplied as stylesheet parameters (see 9.5 Global Variables and Parameters), or returned as the result of an extension function (see 25.124.1 Extension Functions).
There are three ways the result of a transformation may be delivered. (This applies both to the principal result, described here, and also to secondary results, generated using xsl:result-document.)
The raw result (a sequence of values) may be returned directly to the calling application.
A result tree may be constructed from the raw result. By default, a result tree is constructed if the build-tree attribute of the unnamed output definition has the effective valueyes. An API for invoking transformations may allow this setting to be overridden by the calling application. If result tree construction is requested, it is performed as described in 2.3.6.1 Result Tree Construction.
Alternatively, the raw result may be serialized as described in 2.3.6.2 Serializing the Result. The decision whether or not to serialize the result is determined by the rules of transformation API provided by the processor, and is not influenced by anything in the stylesheet.
Note:
This specification does not constrain the design of application programming interfaces or the choice of defaults. In previous versions of this specification, result tree construction was a mandatory process, while serialization was optional. When invoking stylesheet functions directly, however, result tree construction and serialization may be inappropriate as defaults. These considerations may affect the design of APIs.
In previous versions of XSLT, results were delivered either in serialized form (as a character or byte stream), or as a tree. In the latter case processors typically would use either their own tree representation, or a standardized tree representation such as the W3C Document Object Model (DOM) (see [DOM Level 2]), adapted to the data structures offered by the programming language in which the API is defined. To deliver a raw result, processors need to define a representation not only of XDM nodes but also of sequences, atomic items, maps, arrays, and even functions. As with the return of a simple tree, this may involve a trade-off between strict fidelity to the XDM data model and usability in the particular programming language environment. It is not a requirement that an API should return results in a way that exposes every property of the XDM data model; for example there may be APIs that do not expose the precise type annotation of a returned node or atomic item, or that fail to expose the base URI or document URI of a node, or that provide no way of determining whether two nodes in the result sequence are the same node in the sense of the XPath is operator. The way in which maps, arrays, and functions are returned requires careful design choices. It is recommended that an API should be capable of returning any XDM value without error, and that there should be minimal loss of information if the raw results output by one transformation are subsequently used as input to another transformation.
See 2.7 Parsing and Serialization.
The raw result may optionally be serialized as described in 2726 Serialization. The serialization is controlled by the serialization parameters defined in the unnamed output definition of the top-level package.
Note:
The first phase of serialization, called sequence normalizationSER30, takes place for some output methods but not others. For example, if the json output method (defined in [XSLT and XQuery Serialization 4.0]) is selected, then the process of constructing a tree is bypassed.
The effect of serialization is to generate a sequence of octets, representing the serialized result in some character encoding. The processor’s API may define mechanisms enabling this sequence of octets to be written to persistent storage at some location. The default location is the location identified by the base output URI.
In previous versions of this specification it was stated that when the raw result of the initial template or function is an empty sequence, a result tree should be produced if and only if the transformation generates no secondary results (that is, if it does not invoke xsl:result-document). This provision is most likely to have a noticeable effect if the transformation produces serialized results, and these results are written to persistent storage: the effect is then that a transformation producing an empty principal result will overwrite any existing content at the base output URI location if and only if the transformation produces no other output. Processor APIs offering backwards compatibility with earlier versions of XSLT must respect this behavior, but there is no requirement for new processor APIs to do so.
[Definition: The base output URI is a URI to be used as the base URI when resolving a relative URI reference 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.] The way in which a base output URI is established is implementation-defined. Each invocation of the stylesheet may supply a different base output URI. It is acceptable for the base output URI to be absent, provided no constructs (such as xsl:result-document) are evaluated that depend on the value of the base output URI.
Note:
It will often be convenient for the base output URI to be the same as the location to which the principal result document is serialized, but this relationship is not a necessary one.
The main executable components of a stylesheet are templates and functions. The body of a template or function is a sequence constructor, which is a sequence of elements and text nodes that can be evaluated to produce a result.
A sequence constructor is a sequence of sibling nodes in the stylesheet, each of which is either an XSLT instruction, a literal result element, a text node, or an extension instruction.
[Definition: An instruction is either an XSLT instruction or an extension instruction.]
[Definition: An XSLT instruction is an XSLT element whose syntax summary in this specification contains the annotation <!-- category: instruction -->.]
Extension instructions are described in 25.224.2 Extension Instructions.
The main categories of XSLT instruction are as follows:
instructions that create new nodes: xsl:document, xsl:element, xsl:attribute, xsl:processing-instruction, xsl:comment, xsl:value-of, xsl:text, xsl:namespace;
instructions that construct maps and arrays: xsl:array, xsl:array-member, xsl:map, xsl:map-entry;
instructions that copy nodes: xsl:copy, xsl:copy-of;
an instruction that returns an arbitrary sequence by evaluating an XPath expression: xsl:sequence;
instructions that cause conditional or repeated evaluation of nested instructions: xsl:if, xsl:choose, xsl:switch, xsl:try, xsl:for-each, xsl:for-each-group, xsl:fork, xsl:iterate and its subordinate instructions xsl:next-iteration and xsl:break;
instructions that generate output conditionally if elements are or are not empty: xsl:on-empty, xsl:on-non-empty, xsl:where-populated;
instructions that invoke templates: xsl:apply-templates, xsl:apply-imports, xsl:call-template, xsl:next-match;
Instructions that declare variables: xsl:variable;
Instructions to assist debugging: xsl:message, xsl:assert;
other specialized instructions: xsl:number, xsl:analyze-string, xsl:fork, xsl:result-document, xsl:source-document, xsl:perform-sort, xsl:merge.
An XSLT stylesheet describes a process that constructs a set of results from a set of inputs. The inputs are the data provided at stylesheet invocation, as described in 2.3 Initiating a Transformation. The results include the principal result (an arbitrary sequence), which is the result of the initial component invocation, together with any secondary results produced using xsl:result-document instructions.
The stylesheet does not describe how a source tree is constructed. Some possible ways of constructing source trees are described in [XDM 3.0]. Frequently an implementation will operate in conjunction with an XML parser (or more strictly, in the terminology of [XML 1.0], an XML processor), to build a source tree from an input XML document. An implementation may also provide an application programming interface allowing the tree to be constructed directly, or allowing it to be supplied in the form of a DOM Document object (see [DOM Level 2]). This is outside the scope of this specification. Users should be aware, however, that since the input to the transformation is a tree conforming to the XDM data model as described in [XDM 3.0], constructs that might exist in the original XML document, or in the DOM, but which are not within the scope of the data model, cannot be processed by the stylesheet and cannot be guaranteed to remain unchanged in the transformation output. Such constructs include CDATA section boundaries, the use of entity references, and the DOCTYPE declaration and internal DTD subset.
[Definition: 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.]
Like parsing, serialization is not part of the transformation process, and it is not required that an XSLT processor must be able to perform serialization. However, for pragmatic reasons, this specification describes declarations (the xsl:output element and the xsl:character-map declarations, see 2726 Serialization), and attributes on the xsl:result-document instruction, that allow a stylesheet to specify the desired properties of a serialized output file. When serialization is not being performed, either because the implementation does not support the serialization option, or because the user is executing the transformation in a way that does not invoke serialization, then the content of the xsl:output and xsl:character-map declarations has no effect. Under these circumstances the processor may raise any errors in an xsl:output or xsl:character-map declaration, or in the serialization attributes of xsl:result-document, but is not required to do so.
XSLT defines a number of features that allow the language to be extended by implementers, or, if implementers choose to provide the capability, by users. These features have been designed, so far as possible, so that they can be used without sacrificing interoperability. Extensions other than those explicitly defined in this specification are not permitted.
These features are all based on XML namespaces; namespaces are used to ensure that the extensions provided by one implementer do not clash with those of a different implementer.
The most common way of extending the language is by providing additional functions, which can be invoked from XPath expressions. These are known as extension functions, and are described in 25.124.1 Extension Functions.
It is also permissible to extend the language by providing new instructions. These are referred to as extension instructions, and are described in 25.224.2 Extension Instructions. A stylesheet that uses extension instructions in a particular namespace must declare that it is doing so by using the [xsl:]extension-element-prefixes attribute.
Extension instructions and extension functions defined according to these rules may be provided by the implementer of the XSLT processor, and the implementer may also provide facilities to allow users to create further extension instructions and extension functions.
This specification defines how extension instructions and extension functions are invoked, but the facilities for creating new extension instructions and extension functions are implementation-defined. For further details, see 2524 Extensibility and Fallback.
The XSLT language can also be extended by the use of extension attributes (see 3.2 Extension Attributes), and by means of user-defined data elements (see 3.7.4 User-defined Data Elements).
An XSLT stylesheet can make use of information from a schema. An XSLT transformation can take place in the absence of a schema (and, indeed, in the absence of a DTD), but where the source document has undergone schema validity assessment, the XSLT processor has access to the type information associated with individual nodes, not merely to the untyped text.
Information from a schema can be used both statically (when the stylesheet is compiled), and dynamically (during evaluation of the stylesheet to transform a source document).
There are places within a stylesheet, and within XPath expressions and patterns in a stylesheet, where it is possible to refer to named type definitions in a schema, or to element and attribute declarations. For example, it is possible to declare the types expected for the parameters of a function. This is done using a SequenceType.
[Definition: A SequenceType constrains the type and number of items in a sequence. The term is used both to denote the concept, and to refer to the syntactic form in which sequence types are expressed in the XPath grammar: specifically SequenceTypeXP in [XPath 3.0].]
[Definition: Type definitions and element and attribute declarations are referred to collectively as schema components.]
[Definition: The schema components that may be referenced by name in a package are referred to as the in-scope schema components.]
The set of in-scope schema components may vary between one package and another, but as explained in 3.15 Importing Schema Components, the schema components used in different packages must be consistent with each other.
The conformance rules for XSLT 4.0, defined in 2827 Conformance, distinguish between a basic XSLT processor and a schema-aware XSLT processor. As the names suggest, a basic XSLT processor does not support the features of XSLT that require access to schema information, either statically or dynamically. A stylesheet that works with a basic XSLT processor will produce the same results with a schema-aware XSLT processor provided that the source documents are untyped (that is, they are not validated against a schema). However, if source documents are validated against a schema then the results may be different from the case where they are not validated. Some constructs that work on untyped data may fail with typed data (for example, an attribute of type xs:date cannot be used as an argument of the substring function) and other constructs may produce different results depending on the datatype (for example, given the element <product price="10.00" discount="2.00"/>, the expression @price gt @discount will return true if the attributes have type xs:decimal, but will return false if they are untyped).
There is a standard set of type definitions that are always available as in-scope schema components in every stylesheet. These are defined in 3.14 Built-in Types.
The remainder of this section describes facilities that are available only with a schema-aware XSLT processor.
Additional schema components (type definitions, element declarations, and attribute declarations) may be added to the in-scope schema components by means of the xsl:import-schema declaration in a stylesheet.
The xsl:import-schema declaration may reference an external schema document by means of a URI, or it may contain an inline xs:schema element.
It is only necessary to import a schema explicitly if one or more of its schema components are referenced explicitly by name in the stylesheet; it is not necessary to import a schema merely because the stylesheet is used to process a source document that has been assessed against that schema. It is possible to make use of the information resulting from schema assessment (for example, the fact that a particular attribute holds a date) even if no schema has been imported by the stylesheet.
Importing a schema does not of itself say anything about the type of the source document that the stylesheet is expected to process. The imported type definitions can be used for temporary nodes or for nodes on a result tree just as much as for nodes in source documents. It is possible to make assertions about the type of an input document by means of tests within the stylesheet. For example:
<xsl:mode typed="lax"/> <xsl:global-context-item use="required" as="document-node(schema-element(my:invoice))"/>
This example will cause the transformation to fail with an error message, unless the global context item is valid against the top-level element declaration my:invoice, and has been annotated as such.
The setting typed="lax" further ensures that in any match pattern for a template rule in this mode, an element name that corresponds to the name of an element declaration in the schema is taken as referring to elements validated against that declaration: for example, match="employee" will only match a validated employee element. Selecting this option enables the XSLT processor to do more compile-time type-checking against the schema, for example it allows the processor to produce warning or error messages when path expressions contain misspelt element names, or confuse an element with an attribute.
It is also true that importing a schema does not of itself say anything about the structure of the result tree. It is possible to request validation of a result tree against the schema by using the xsl:result-document instruction, for example:
<xsl:template match="/"> <xsl:result-document validation="strict"> <xhtml:html> <xsl:apply-templates/> </xhtml:html> </xsl:result-document> </xsl:template>
This example will cause the transformation to fail with an error message unless the document element of the result document is valid against the top-level element declaration xhtml:html.
It is possible that a source document may contain nodes whose type annotation is not one of the types imported by the stylesheet. This creates a potential problem because in the case of an expression such as data(.) instance of xs:integer the system needs to know whether the type named in the type annotation of the context node is derived by restriction from the type xs:integer. This information is not explicitly available in an XDM tree, as defined in [XDM 3.0]. The implementation may choose one of several strategies for dealing with this situation:
The processor may raise a dynamic error if a source document is found to contain a type annotation that is not known to the processor.
The processor may maintain additional metadata, beyond that described in [XDM 3.0], that allows the source document to be processed as if all the necessary schema information had been imported using xsl:import-schema. Such metadata might be held in the data structure representing the source document itself, or it might be held in a system catalog or repository.
The processor may be configured to use a fixed set of schemas, which are automatically used to validate all source documents before they can be supplied as input to a transformation. In this case it is impossible for a source document to have a type annotation that the processor is not aware of.
The processor may be configured to treat the source document as if no schema processing had been performed, that is, effectively to strip all type annotations from elements and attributes on input, marking them instead as having type xs:untyped and xs:untypedAtomic respectively.
Where a stylesheet author chooses to make assertions about the types of nodes or of variables and parameters, it is possible for an XSLT processor to perform static analysis of the stylesheet (that is, analysis in the absence of any source document). Such analysis may reveal errors that would otherwise not be discovered until the transformation is actually executed. An XSLT processor is not required to perform such static type-checking. Under some circumstances (see 2.14 Error Handling) type errors that are detected early may be raised as static errors. In addition an implementation may report any condition found during static analysis as a warning, provided that this does not prevent the stylesheet being evaluated as described by this specification.
A stylesheet can also control the type annotations of nodes that it constructs in a result tree. This can be done in a number of ways.
It is possible to request explicit validation of a complete document, that is, a result tree rooted at a document node. Validation is either strict or lax, as described in [XML Schema Part 1]. If validation of a result tree fails (strictly speaking, if the outcome of the validity assessment is invalid), then the transformation fails, but in all other cases, the element and attribute nodes of the tree will be annotated with the names of the types to which these nodes conform. These type annotations will be discarded if the result tree is serialized as an XML document, but they remain available when the result tree is passed to an application (perhaps another stylesheet) for further processing.
It is also possible to validate individual element and attribute nodes as they are constructed. This is done using the type and validation attributes of the xsl:element, xsl:attribute, xsl:copy, and xsl:copy-of instructions, or the xsl:type and xsl:validation attributes of a literal result element.
When elements, attributes, or document nodes are copied, either explicitly using the xsl:copy or xsl:copy-of instructions, or implicitly when nodes in a sequence are attached to a new parent node, the options validation="strip" and validation="preserve" are available, to control whether existing type annotations are to be retained or not.
When nodes in a temporary tree are validated, type information is available for use by operations carried out on the temporary tree, in the same way as for a source document that has undergone schema assessment.
For details of how validation of element and attribute nodes works, see 26.425.4 Validation.
[Definition: An error that can be 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.]
Generally, errors in the structure of the stylesheet, or in the syntax of XPath expressions contained in the stylesheet, are classified as static errors. Where this specification states that an element in the stylesheet must or must not appear in a certain position, or that it must or must not have a particular attribute, or that an attribute must or must not have a value satisfying specified conditions, then any contravention of this rule is a static error unless otherwise specified.
A processor must provide a mode of operation that takes a (possibly erroneous) stylesheet package as input and enables the user to determine whether or not that package contains any static errors.
Note:
The manner in which static errors are reported, and the behavior when there are multiple static errors, are left as design choices for the implementer. It is recommended that the error codes defined in this specification should be made available in any diagnostics.
A processor may also provide a mode of operation in which static errors in parts of the stylesheet that are not evaluated can go unreported.
Note:
For example, when operating in this mode, a processor might report static errors in a template rule only if the input document contains nodes that match that template rule. Such a mode of operation can provide performance benefits when large and well-tested stylesheets are used to process source documents that might only use a small part of the XML vocabulary that the stylesheet is designed to handle.
[Definition: An error that is not capable of detection until a source document is being transformed is referred to as a dynamic error.]
When a dynamic error occurs, and is not caught using xsl:catch, the processormust raise the error, and the transformation fails.
Because different implementations may optimize execution of the stylesheet in different ways, the detection of dynamic errors is to some degree implementation-dependent. In cases where an implementation is able to produce a principal result or secondary result without evaluating a particular construct, the implementation is never required to evaluate that construct solely in order to determine whether doing so causes a dynamic error. For example, if a variable is declared but never referenced, an implementation may choose whether or not to evaluate the variable declaration, which means that if evaluating the variable declaration causes a dynamic error, some implementations will raise this error and others will not.
There are some cases where this specification requires that a construct must not be evaluated: for example, the content of an xsl:if instruction must not be evaluated if the test condition is false. This means that an implementation must not raise any dynamic errors that would arise if the construct were evaluated.
An implementation may raise a dynamic error before any source document is available, but only if it can determine that the error would be raised for every possible source document and every possible set of parameter values. For example, some circularity errors fall into this category: see 9.11 Circular Definitions.
There are also some dynamic errors where the specification gives a processor license to raise the error during the analysis phase even if the construct might never be executed; an example is the use of an invalid QName as a literal argument to a function such as key, or the use of an invalid regular expression in the regex attribute of the xsl:analyze-string instruction.
A dynamic error is also raised during the static analysis phase if the error occurs during evaluation of a static expression.
The XPath specification states (see Section 2.4.1 Kinds of ErrorsXP) that if any expression (at any level) can be evaluated during the analysis phase (because all its explicit operands are known and it has no dependencies on the dynamic context), then any error in performing this evaluation may be raised as a static error. For XPath expressions used in an XSLT stylesheet, however, any such errors must not be raised as static errors in the stylesheet unless they would occur in every possible evaluation of that stylesheet; instead, they must be raised as dynamic errors, and raised only if the XPath expression is actually evaluated.
An XPath processor may report statically that the expression 1 div 0 fails with a “divide by zero” error. But suppose this XPath expression occurs in an XSLT construct such as:
<xsl:choose> <xsl:when test="system-property('xsl:version') = '1.0'"> <xsl:value-of select="1 div 0"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="xs:double('INF')"/> </xsl:otherwise> </xsl:choose>
Then the XSLT processor must not report an error, because the relevant XPath construct appears in a context where it will never be executed by an XSLT 4.0. (An XSLT 1.0 processor will execute this code successfully, returning positive infinity, because it uses double arithmetic rather than decimal arithmetic.)
[Definition: 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.] If a type error occurs in an instruction that is actually evaluated, then it must be raised in the same way as a dynamic error. Alternatively, an implementation may raise a type error during the analysis phase in the same way as a static error, even if it occurs in part of the stylesheet that is never evaluated, provided it can establish that execution of a particular construct would never succeed.
It is implementation-defined whether type errors are raised statically.
The following construct contains a type error, because 42 is not allowed as the value of the select expression of the xsl:number instruction (it must be a node). An implementation may optionally raise this as a static error, even though the offending instruction will never be evaluated, and the type error would therefore never be raised as a dynamic error.
<xsl:if test="false()"> <xsl:number select="42"/> </xsl:if>
On the other hand, in the following example it is not possible to determine statically whether the operand of xsl:number will have a suitable dynamic type. An implementation may produce a warning in such cases, but it must not treat it as an error.
<xsl:template match="para"> <xsl:param name="p" as="item()"/> <xsl:number select="$p"/> </xsl:template>
If more than one error arises, an implementation is not required to raise any errors other than the first one that it detects. It is implementation-dependent which of the several errors is raised. This applies both to static errors and to dynamic errors. An implementation is allowed to raise more than one error, but if any errors have been raised, it must not finish as if the transformation were successful.
When a transformation raises one or more dynamic errors, the final state of any persistent resources updated by the transformation is implementation-dependent. Implementations are not required to restore such resources to their initial state. In particular, where a transformation produces multiple result documents, it is possible that one or more serialized result documents may be written successfully before the transformation terminates, but the application cannot rely on this behavior.
Everything said above about error handling applies equally to errors in evaluating XSLT instructions, and errors in evaluating XPath expressions. Static errors and dynamic errors may occur in both cases.
[Definition: If a transformation has successfully produced a principal result or secondary result, it is still possible that errors may occur in serializing that result . For example, it may be impossible to serialize the result using the encoding selected by the user. Such an error is referred to as a serialization error.] If the processor performs serialization, then it must do so as specified in 2726 Serialization, and in particular it must raise any serialization errors that occur.
Errors are identified by a QName. For errors defined in this specification, the namespace of the QName is always http://www.w3.org/2005/xqt-errors (and is therefore not given explicitly), while the local part is an 8-character code in the form PPSSNNNN. Here PP is always XT (meaning XSLT), and SS is one of SE (static error), DE (dynamic error), or TE (type error). Note that the allocation of an error to one of these categories is purely for convenience and carries no normative implications about the way the error is handled. Many errors, for example, can be raised either dynamically or statically. These error codes are used to label error conditions in this specification, and are summarized in ED Summary of Error Conditions.
Errors defined in related specifications ([XPath 4.0], [Functions and Operators 4.0][XSLT and XQuery Serialization]) use QNames with a similar structure, in the same namespace. When errors occur in processing XPath expressions, an XSLT processor should use the original error code reported by the XPath processor, unless a more specific XSLT error code is available.
Implementations must use the codes defined in these specifications when raising dynamic errors, to ensure that xsl:catch behaves in an interoperable way across implementations. Stylesheet authors should note, however, that there are many examples of errors where more than one rule in this specification is violated, and where the processor therefore has discretion in deciding which error code to associate with the condition: there is therefore no guarantee that different processors will always use the same error code for the same erroneous input.
Additional errors defined by an implementation (or by an application) may use QNames in an implementation-defined (or user-defined) namespace without risk of collision.
This section describes the overall structure of a stylesheet as a collection of XML documents.
A stylesheet module is typically written as a namespace well-formed XML document: more formally, as described in 3.6 Stylesheet Modules, a stylesheet module takes the form of an XDM tree rooted at an element node.
The names of elements and attributes in source documents and result documents are namespace-qualified names. In addition, as described in 5.1.1 Qualified Names, XSLT uses namespace-qualified names to identify variables, functions, templates, and other components. These names generally use namespace prefixes that are resolved to namespace URIs using a set of prefix-uri namespace bindings.
There are two ways namespace bindings can be established in a stylesheet module:
[Definition: The native namespace bindings for any element in an XSLT stylesheet module are the prefix-uri mappings defined by the namespace nodes of that element, according to the rules in [XDM 3.0].]
For example, a namespace declaration of the form xmlns:math="http://www.w3.org/2005/xpath-functions/math establishes a binding of the prefix math to the namespace URI http://www.w3.org/2005/xpath-functions/math, thereby enabling functions in that namespace to be invoked using an expression such as math:sin($theta)
[Definition: The fixed namespace bindings for a stylesheet module are established using the fixed-namespaces attribute on the xsl:stylesheet, xsl:transform, or xsl:package element enclosing the stylesheet module.]
For example, the attribute fixed-namespaces="math map array" establishes bindings for the prefixes math, map, and array to the namespace URIs conventionally associated with these prefixes as described in 5.1.3 Reserved Namespaces.
Prefixes used in element and attribute names in the stylesheet, because these are interpreted by the XML parser and not only by the XSLT processor, must be bound using native namespace bindings. In particular, the XSLT namespace is used in the names of XSLT elements, so it must be declared in every stylesheet module using a namespace declaration such as xmlns:xsl="http://www.w3.org/1999/XSL/Transform. (A different prefix can be used: some users prefer xslt, some favor the default namespace.) But namespace prefixes that are only used within the content of attribute and text nodes in the stylesheet (for example, select="math:sin($theta)") can be declared in fixed namespace bindings.
[Definition: The applicable static namespaces for an element in a stylesheet module are the fixed namespace bindings for the module if the root element of the module has a fixed-namespaces attribute, or the native namespace bindings of the element otherwise. ]
The effect of declaring fixed namespace bindings is described in more detail in 3.7.1 The fixed-namespaces Attribute.
Note:
As a general rule:
Prefixes used in the names of elements and attributes in the stylesheet must be declared using native namespace bindings.
Prefixes used in QNames appearing in the content of attribute nodes and text nodes in the stylesheet can usually be declared using fixed namespace bindings. There are a small number of exceptions, notably the standard attributes [xsl:]exclude-result-prefixes and [xsl:]extension-element-prefixes, and the stylesheet-prefix and result-prefix attributes of xsl:namespace-alias.
[Definition: 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.]
Note:
The 1999 in the URI indicates the year in which the URI was allocated by the W3C. It does not indicate the version of XSLT being used, which is specified by attributes (see 3.7 Stylesheet Element and 3.8 Simplified Stylesheet Modules).
XSLT processorsmust use the XML namespaces mechanism [Namespaces in XML] to recognize elements and attributes from this namespace. Elements from the XSLT namespace are recognized only in the stylesheet and not in the source document. The complete list of XSLT-defined elements is specified in DC Element Syntax Summary. Implementationsmust not extend the XSLT namespace with additional elements or attributes. Instead, any extension must be in a separate namespace. Any namespace that is used for additional instruction elements must be identified by means of the extension instruction mechanism specified in 25.224.2 Extension Instructions.
Except where the rules for forwards compatible behavior dictate otherwise, it is a static error for any element in the stylesheet to be in the XSLT namespace unless it is an element defined in this specification [see ERR XTSE0010].
This specification uses a prefix of xsl: for referring to elements in the XSLT namespace. However, XSLT stylesheets are free to use any prefix, provided that there is a namespace declaration that binds the prefix to the URI of the XSLT namespace.
Note:
Throughout this specification, an element or attribute that is in no namespace, or an expanded QName whose namespace part is an empty sequence, is referred to as having a null namespace URI.
Note:
By convention, the names of XSLT elements, attributes and functions are all lower-case; they use hyphens to separate words, and they use abbreviations only if these already appear in the syntax of a related language such as XML or HTML. Names of types defined in XML Schema are regarded as single words and are capitalized exactly as in XML Schema. This sometimes leads to composite function names such as current-dateTime.
[Definition: There are a number of standard attributes that may appear on any XSLT element: specifically default-collation, default-mode, default-validation, exclude-result-prefixes, expand-text, extension-element-prefixes, use-when, version, and xpath-default-namespace.]
These attributes may also appear on a literal result element, but in this case, to distinguish them from user-defined attributes, the names of the attributes are in the XSLT namespace. They are thus typically written as xsl:default-collation, xsl:default-mode, xsl:default-validation, xsl:exclude-result-prefixes, xsl:expand-text, xsl:extension-element-prefixes, xsl:use-when, xsl:version, or xsl:xpath-default-namespace.
It is recommended that all these attributes should also be permitted on extension instructions, but this is at the discretion of the implementer of each extension instruction. They may also be permitted on user-defined data elements, though they will only have any useful effect in the case of data elements that are designed to behave like XSLT declarations or instructions.
In the following descriptions, these attributes are referred to generically as [xsl:]version, and so on.
These attributes all affect the element they appear on, together with any elements and attributes that have that element as an ancestor. The two forms with and without the XSLT namespace have the same effect; the XSLT namespace is used for the attribute if and only if its parent element is not in the XSLT namespace.
In the case of [xsl:]default-collation, [xsl:]expand-text, [xsl:]version, and [xsl:]xpath-default-namespace, the value can be overridden by a different value for the same attribute appearing on a descendant element. The effective value of the attribute for a particular stylesheet element is determined by the innermost ancestor-or-self element on which the attribute appears.
In an embedded stylesheet module, standard attributes appearing on ancestors of the outermost element of the stylesheet module have no effect.
In the case of [xsl:]exclude-result-prefixes and [xsl:]extension-element-prefixes the values are cumulative. For these attributes, the value is given as a whitespace-separated list of namespace prefixes, and the effective value for an element is the combined set of namespace URIs designated by the prefixes that appear in this attribute for that element and any of its ancestor elements. Again, the two forms with and without the XSLT namespace are equivalent.
The effect of the [xsl:]use-when attribute is described in 3.13.3 Conditional Element Inclusion.
Because these attributes may appear on any XSLT element, they are not listed in the syntax summary of each individual element. Instead they are listed and described in the entry for the xsl:stylesheet, xsl:transform, and xsl:package elements only. This reflects the fact that these attributes are often used on the outermost element of the stylesheet, in which case they apply to the entire stylesheet module or package manifest.
Note that the effect of these attributes does not extend to stylesheet modules referenced by xsl:include or xsl:import declarations, nor to packages referenced using xsl:use-package.
For the detailed effect of each attribute, see the following sections:
[xsl:]default-collation[xsl:]default-mode[xsl:]default-validation[xsl:]exclude-result-prefixes[xsl:]expand-text[xsl:]extension-element-prefixes[xsl:]use-when[xsl:]versionsee 3.9 Backwards Compatible Processing and 3.10 Forwards Compatible Processing
[xsl:]xpath-default-namespacesee 5.1.2 Unprefixed Lexical QNames in Expressions and Patterns
A new attribute, main-module, is added to the xsl:stylesheet element. The attribute is provided for the benefit of development tools such as syntax-directed editors to provide information about all the components (variables, functions, etc) visible within a stylesheet module. [Issue 87 PR 353 19 April 2023]
<xsl:stylesheet
id? = id
version = decimal
default-mode? = eqname | "#unnamed"〔'#unnamed'〕
default-validation? = "preserve" | "strip"〔'strip'〕
input-type-annotations? = "preserve" | "strip" | "unspecified"〔'unspecified'〕
default-collation? = uris
extension-element-prefixes? = prefixes
exclude-result-prefixes? = prefixes
expand-text? = boolean
fixed-namespaces? = string
main-module? = uri
use-when? = expression〔true()〕
xpath-default-namespace? = uri >
<!-- Content: (declarations) -->
</xsl:stylesheet>
<xsl:transform
id? = id
version = decimal
default-mode? = eqname | "#unnamed"〔'#unnamed'〕
default-validation? = "preserve" | "strip"〔'strip'〕
input-type-annotations? = "preserve" | "strip" | "unspecified"〔'unspecified'〕
default-collation? = uris
extension-element-prefixes? = prefixes
exclude-result-prefixes? = prefixes
expand-text? = boolean〔'no'〕
fixed-namespaces? = string
main-module? = uri
use-when? = expression〔true()〕
xpath-default-namespace? = uri >
<!-- Content: (declarations) -->
</xsl:transform>
A stylesheet module is represented by an xsl:stylesheet element in an XML document. xsl:transform is allowed as a synonym for xsl:stylesheet; everything this specification says about the xsl:stylesheet element applies equally to xsl:transform.
The version attribute indicates the version of XSLT that the stylesheet module requires. The attribute is required.
[ERR XTSE0110] The value of the version attribute must be a number: specifically, it must be a valid instance of the type xs:decimal as defined in [XML Schema Part 2].
The version attribute is intended to indicate the version of the XSLT specification against which the stylesheet is written. In a stylesheet written to use XSLT 4.0, the value should normally be set to 4.0. If the value is numerically less than 4.0, the stylesheet is processed using the rules for backwards compatible behavior (see 3.9 Backwards Compatible Processing). If the value is numerically greater than 4.0, the stylesheet is processed using the rules for forwards compatible behavior (see 3.10 Forwards Compatible Processing).
The effect of the input-type-annotations attribute is described in 4.3.1 Stripping Type Annotations from a Source Tree.
The [xsl:]default-validation attribute defines the default value of the validation attribute of all relevant instructions appearing within its scope. For details of the effect of this attribute, see 26.425.4 Validation.
The optional main-module attribute is purely documentary. By including this attribute in every stylesheet module of a package, an XSLT editing tool may be enabled to locate the top-level module of the relevant package, and thus to gather information about all the global variables, templates, and functions available within the module being edited. This information can be used (for example) to enable auto-completion and error highlighting of the code as it is entered. Note that it may be inconvenient or misleading to use this attribute when the stylesheet module is used as a shared component within multiple stylesheets.
[ERR XTSE0120] An xsl:stylesheet, xsl:transform, or xsl:package element must not have any text node children. (This rule applies after stripping of whitespace text nodes as described in 3.13.1 Stripping Whitespace and Commentary from the Stylesheet.)
[Definition: An element occurring as a child of an xsl:package, xsl:stylesheet, xsl:transform, or xsl:override element is called a top-level element.]
[Definition: 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 3.7.4 User-defined Data Elements)].
The declaration elements permitted in the xsl:stylesheet element are:
xsl:accumulatorxsl:attribute-setxsl:character-mapxsl:decimal-formatxsl:functionxsl:global-context-itemxsl:importxsl:import-schemaxsl:includexsl:item-typexsl:keyxsl:modexsl:namespace-aliasxsl:outputxsl:paramxsl:preserve-spacexsl:record-typexsl:strip-spacexsl:templatexsl:use-packagexsl:variable
Note that the xsl:variable and xsl:param elements can act either as declarations or as instructions. A global variable or parameter is defined using a declaration; a local variable or parameter using an instruction.
The child elements of the xsl:stylesheet element may appear in any order. In most cases, the ordering of these elements does not affect the results of the transformation; however:
As described in 6.5 Conflict Resolution for Template Rules, when two template rules with the same priority match the same nodes, there are situations where the order of the template rules will affect which is chosen.
Forwards references to static variables are not allowed in static expressions.
[Definition: In addition to declarations, the xsl:stylesheet element may contain among its children 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.]
[ERR XTSE0130] It is a static error if an xsl:stylesheet, xsl:transform, or xsl:package element has a child element whose name has a null namespace URI.
An implementation may attach an implementation-defined meaning to user-defined data elements that appear in particular namespaces. The set of namespaces that are recognized for such data elements is implementation-defined. The presence of a user-defined data element must not change the behavior of XSLT elements and functions defined in this document; for example, it is not permitted for a user-defined data element to specify that xsl:apply-templates should use different rules to resolve conflicts. The constraints on what user-defined data elements can and cannot do are exactly the same as the constraints on extension attributes, described in 3.2 Extension Attributes. Thus, an implementation is always free to ignore user-defined data elements, and must ignore such data elements without giving an error if it does not recognize the namespace URI.
User-defined data elements can provide, for example,
information used by extension instructions or extension functions (see 2524 Extensibility and Fallback),
information about what to do with any final result tree,
information about how to construct source trees,
optimization hints for the processor,
metadata about the stylesheet,
structured documentation for the stylesheet.
[Definition: The effective version of an element in a stylesheet module or package manifest is the decimal value of the [xsl:]version attribute (see 3.4 Standard Attributes) on that element or on the innermost ancestor element that has such an attribute, subject to special rules for the xsl:output and xsl:fallback elements.]
These rules do not apply to the xsl:output element, whose version attribute has an entirely different purpose: it is used to define the version of the output method to be used for serialization. The effective version of an xsl:output element is the effective version of its parent element.
There are additional rules for an xsl:fallback element: see 3.10 Forwards Compatible Processing.
[Definition: An element is processed with backwards compatible behavior if its effective version is less than 4.0.]
Specifically:
If the effective version is equal to 1.0, then the element is processed with XSLT 1.0 behavior as described in 3.9.1 XSLT 1.0 Compatibility Mode.
If the effective version is equal to 2.0, then the element is processed with XSLT 2.0 behavior as described in 3.9.2 XSLT 2.0 Compatibility Mode.
If the effective version is equal to 3.0, then the element is processed with XSLT 3.0 behavior as described in 3.9.3 XSLT 3.0 Compatibility Mode.
If the effective version is any other value less than 4.0, the recommended action is to raise a static error; however, processors may recognize such values and process the element in an implementation-defined way.
Note:
XSLT 1.0 allowed the version attribute to take any decimal value, and invoked forwards compatible processing for any value other than 1.0. XSLT 2.0 allowed the attribute to take any decimal value, and invoked backwards compatible (i.e. 1.0-compatible) processing for any value less than 2.0. Some stylesheets may therefore be encountered that use values other than 1.0 or 2.0. In particular, the value 1.1 is sometimes encountered, as it was used at one stage in a draft language proposal.
It is implementation-defined whether a particular XSLT 4.0 implementation supports backwards compatible behavior for any XSLT version earlier than XSLT 4.0.
[ERR XTDE0160] It is a dynamic error if an element has an effective version of V (with V < 4.0) when the implementation does not support backwards compatible behavior for XSLT version V.
Note:
By making use of backwards compatible behavior, it is possible to write the stylesheet in a way that ensures that its results when processed with an XSLT 4.0 processor are identical to the effects of processing the same stylesheet using a processor for an earlier version of XSLT. To assist with transition, some parts of a stylesheet may be processed with backwards compatible behavior enabled, and other parts with this behavior disabled.
All data values manipulated by an XSLT 4.0 processor are defined by the XDM data model, whether or not the relevant expressions use backwards compatible behavior. Because the same data model is used in both cases, expressions are fully composable. The result of evaluating instructions or expressions with backwards compatible behavior is fully defined in the XSLT 4.0 and XPath 4.0 specifications, it is not defined by reference to earlier versions of the XSLT and XPath specifications.
To write a stylesheet that makes use of features that are new in version N, while also working with a processor that only supports XSLT version M (M < N), it is necessary to understand both the rules for backwards compatible behavior in XSLT version N, and the rules for forwards compatible behavior in XSLT version M. If the xsl:stylesheet element specifies a version attribute with a value greater than 1.0, then an XSLT 1.0 processor will ignore declarations that were not defined in XSLT 1.0, for example xsl:function, xsl:import-schema, and xsl:mode. If any new XSLT 4.0 instructions are used (for example xsl:switch or xsl:array), or if new XPath 4.0 features are used (for example, keyword arguments in function calls), then the stylesheet must provide fallback behavior that relies only on facilities available in the earliest XSLT version supported. The fallback behavior can be invoked by using the xsl:fallback instruction, or by testing the results of the function-available or element-available functions, or by testing the value of the xsl:version property returned by the system-property function.
[Definition: An element in the stylesheet is processed with XSLT 1.0 behavior if its effective version is equal to 1.0.]
In this mode, if any attribute contains an XPath expression, then the expression is evaluated with XPath 1.0 compatibility mode set to true. For details of this mode, see Section 2.2.1 Static ContextXP. Expressions contained in text value templates are always evaluated with XPath 1.0 compatibility mode set to false, since this construct was not available in XSLT 1.0.
Furthermore, in such an expression any function call for which no implementation is available (unless it uses the standard function namespace) is bound to a fallback error function whose effect when evaluated is to raise a dynamic error [see ERR XTDE1425] . The effect is that with backwards compatible behavior enabled, calls on extension functions that are not available in a particular implementation do not cause an error unless the function call is actually evaluated. For further details, see 25.124.1 Extension Functions.
Note:
This might appear to contradict the specification of XPath 3.0, which states that a static error [XPST0017] is raised when an expression contains a call to a function that is not present (with matching name and arity) in the static context. This apparent contradiction is resolved by specifying that the XSLT processor constructs a static context for the expression in which every possible function name and arity (other than names in the standard function namespace) is present; when no other implementation of the function is available, the function call is bound to a fallback error function whose run-time effect is to raise a dynamic error.
Certain XSLT constructs also produce different results when XSLT 1.0 compatibility mode is enabled. This is described separately for each such construct.
Processing an instruction with XSLT 1.0 behavior is not compatible with streaming. More specifically, and notwithstanding anything stated in 19 Streamability, an instruction that is processed with XSLT 1.0 behavior is roaming and free-ranging, which has the effect that any construct containing such an instruction is not guaranteed-streamable.
The intent of forwards compatible behavior is to make it possible to write a stylesheet that takes advantage of features introduced in some version of XSLT subsequent to XSLT 4.0, while retaining the ability to execute the stylesheet with an XSLT 4.0 processor using appropriate fallback behavior.
It is always possible to write conditional code to run under different XSLT versions by using the use-when feature described in 3.13.3 Conditional Element Inclusion. The rules for forwards compatible behavior supplement this mechanism in two ways:
Certain constructs in the stylesheet that mean nothing to an XSLT 4.0 processor are ignored, rather than being treated as errors.
Explicit fallback behavior can be defined for instructions defined in a future XSLT release, using the xsl:fallback instruction.
The detailed rules follow.
[Definition: An element is processed with forwards compatible behavior if its effective version is greater than 4.0.]
These rules do not apply to the version attribute of the xsl:output element, which has an entirely different purpose: it is used to define the version of the output method to be used for serialization.
When an element is processed with forwards compatible behavior:
If the element is in the XSLT namespace and appears as a child of the xsl:stylesheet element, and XSLT 4.0 does not allow the element to appear as a child of the xsl:stylesheet element, then the element and its content must be ignored.
If the element has an attribute that XSLT 4.0 does not allow the element to have, then the attribute must be ignored.
If the element is in the XSLT namespace and appears as a child of an element whose content model requires a sequence constructor, and XSLT 4.0 does not allow such elements to appear as part of a sequence constructor, then:
If the element has one or more xsl:fallback children, then no error is raised either statically or dynamically, and the result of evaluating the instruction is the concatenation of the sequences formed by evaluating the sequence constructors within its xsl:fallback children, in document order. Siblings of the xsl:fallback elements are ignored, even if they are valid XSLT 4.0 instructions.
If the element has no xsl:fallback children, then a static error is raised in the same way as if forwards compatible behavior were not enabled.
For example, an XSLT 4.0 processor will process the following stylesheet without error, although the stylesheet includes elements from the XSLT namespace that are not defined in this specification:
<xsl:stylesheet version="17.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:exciting-new-17.0-feature> <xsl:fly-to-the-moon/> <xsl:fallback> <html> <head> <title>XSLT 17.0 required</title> </head> <body> <p>Sorry, this stylesheet requires XSLT 17.0.</p> </body> </html> </xsl:fallback> </xsl:exciting-new-17.0-feature> </xsl:template> </xsl:stylesheet>
Note:
If a stylesheet depends crucially on a declaration introduced by a version of XSLT after 4.0, then the stylesheet can use an xsl:message element with terminate="yes" (see 24.123.1 Messages) to ensure that implementations that conform to an earlier version of XSLT will not silently ignore the declaration.
For example,
<xsl:stylesheet version="18.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:important-new-17.0-declaration/> <xsl:template match="/"> <xsl:choose> <xsl:when test="number(system-property('xsl:version')) lt 17.0"> <xsl:message terminate="yes"> <xsl:text>Sorry, this stylesheet requires XSLT 17.0.</xsl:text> </xsl:message> </xsl:when> <xsl:otherwise> ... </xsl:otherwise> </xsl:choose> </xsl:template> ... </xsl:stylesheet>
Note:
The XSLT 1.0 and XSLT 2.0 specifications did not anticipate the introduction of the xsl:package element. An XSLT 1.0 or 2.0 processor encountering this element will raise a static error, regardless of the version setting.
This problem can be circumvented by using the simplified package syntax (whereby an xsl:stylesheet element is implicitly treated as xsl:package), or by writing the stylesheet code in a separate module from the package manifest, and using the separate module as the version of the stylesheet that is presented to a 2.0 processor.
For an XSLT 4.0 processor, the effective version of an xsl:fallback element that has no explicit version attribute is 4.0: more generally, it is the version of XSLT supported by the processor. This rule is designed to ensure that the xsl:fallback element itself is not processed with forwards compatible behavior, which would be pointless since the whole purpose of the instruction is to provide code that can be evaluated with an earlier version of XSLT.
Note:
This rule was not present in earlier versions of this specification. On a strict reading of the XSLT 3.0 specification, for example, an xsl:fallback instruction with no version attribute is evaluated with forwards compatible behavior. This means, for example, that if the stylesheet author writes <xsl:fallback select="42"/> (which is incorrect, because the instruction does not define a select attribute) then the select attribute will simply be ignored.
Stylesheet authors can prevent this problem by adding an explicit version attribute to xsl:fallback indicating the version of XSLT that is needed to evaluate the fallback code.
This specification cannot retrospectively dictate what XSLT 3.0 (or earlier) processors should do; however, developers of such processors are encouraged to adopt this rule, so that in an XSLT 4.0 stylesheet, an xsl:fallback instruction that cannot be properly evaluated by an XSLT 3.0 processor is rejected rather than being silently ignored.
Every XSLT 4.0 processor includes the following named type definitions in the in-scope schema components:
All built-in types defined in [XML Schema Part 2], including xs:anyType and xs:anySimpleType.
The following types defined in [XPath 3.0]: xs:yearMonthDuration, xs:dayTimeDuration, xs:anyAtomicType, xs:untyped, and xs:untypedAtomic.
XSLT 4.0 processors may optionally include types defined in XSD 1.1 (see [XML Schema 1.1 Part 1]). XSD 1.1 adopts the types xs:yearMonthDuration, xs:dayTimeDuration, and xs:anyAtomicType previously defined in XPath 2.0, and adds one new type: xs:dateTimeStamp. XSD 1.1 also allows implementers to define additional primitive types, and XSLT 4.0 permits such types to be supported by an XSLT processor.
A schema-aware XSLT processor additionally supports:
User-defined types, and element and attribute declarations, that are imported using an xsl:import-schema declaration as described in 3.15 Importing Schema Components. These may include both simple and complex types.
Note:
The names that are imported from the XML Schema namespace do not include all the names of top-level types defined in either the Schema for Schema Documents or the Schema for Schema Documents (Datatypes). The Schema for Schema Documents, as well as defining built-in types such as xs:integer and xs:double, also defines types that are intended for use only within that schema, such as xs:derivationControl. A stylesheet that is designed to process XML Schema documents as its input or output may import the Schema for Schema Documents.
An implementation may define mechanisms that allow additional schema components to be added to the in-scope schema components for the stylesheet. For example, the mechanisms used to define extension functions (see 25.124.1 Extension Functions) may also be used to import the types used in the interface to such functions.
These schema components are the only ones that may be referenced in XPath expressions within the stylesheet, or in the [xsl:]type and as attributes of those elements that permit these attributes.
The rules concerning the compatibility of schemas imported by different packages have been clarified. It is now explicitly stated that instructions that trigger validation must use the imported schema of the package in which validation is invoked. This differs from the current practice of some XSLT 3.0 processors, which may use (for example) a schema formed from the union of the imported schemas in all packages. [Issue 451 PR 635 24 October 2023]
Note:
The facilities described in this section are not available with a basic XSLT processor. They require a schema-aware XSLT processor, as described in 2827 Conformance.
<!-- Category: declaration -->
<xsl:import-schema
namespace? = uri
schema-location? = uri >
<!-- Content: xs:schema? -->
</xsl:import-schema>
The xsl:import-schema declaration is used to identify schema components (that is, top-level type definitions and top-level element and attribute declarations) that need to be available statically, that is, before any source document is available. Names of such components used statically within the stylesheet must refer to an in-scope schema component, which means they must either be built-in types as defined in 3.14 Built-in Types, or they must be imported using an xsl:import-schema declaration.
The xsl:import-schema declaration identifies a namespace containing the names of the components to be imported (or indicates that components whose names are in no namespace are to be imported). The effect is that the names of top-level element and attribute declarations and type definitions from this namespace (or non-namespace) become available for use within XPath expressions in the package, and within other stylesheet constructs such as the type and as attributes of various XSLT elements.
The same schema components are available in all stylesheet modules within the declaring package; importing components in one stylesheet module makes them available throughout the package.
The schema components imported into different packages within a stylesheet must be compatibleDM. Specifically, it is not permitted to use the same name in the same XSD symbol space to refer to different schema components within different packages; and the union of the schema components imported into the packages of a stylesheet must constitute a valid schema (as well as the set of schema components imported into each package forming a valid schema in its own right).
Note:
The fact that the schemas used in different packages must be compatible does not mean they must be identical. There are circumstances where validating an element using one schema might produce a different outcome from validation with a different schema, despite these consistency rules: an example is where the two schemas define different membership for a substitution group.
Nevertheless, the consistency rules are strong enough to ensure that an element node validated using one schema can safely be passed to a function declared in another package, where the function declares the required type of an argument as (say) element(*, T).
The namespace and schema-location attributes are both optional.
If the xsl:import-schema element contains an xs:schema element, then the schema-location attribute must be absent, and one of the following must be true:
the namespace attribute of the xsl:import-schema element and the targetNamespace attribute of the xs:schema element are both absent (indicating a no-namespace schema), or
the namespace attribute of the xsl:import-schema element and the targetNamespace attribute of the xs:schema element are both present and both have the same value, or
the namespace attribute of the xsl:import-schema element is absent and the targetNamespace attribute of the xs:schema element is present, in which case the target namespace is as given on the xs:schema element.
[ERR XTSE0215] It is a static error if an xsl:import-schema element that contains an xs:schema element has a schema-location attribute, or if it has a namespace attribute that conflicts with the target namespace of the contained schema.
If two xsl:import-schema declarations specify the same namespace, or if both specify no namespace, then only the one with highest import precedence is used. If this leaves more than one, then all the declarations at the highest import precedence are used (which may cause conflicts, as described below).
After discarding any xsl:import-schema declarations under the above rule, the effect of the remaining xsl:import-schema declarations is defined in terms of a hypothetical document called the synthetic schema document, which is constructed as follows. The synthetic schema document defines an arbitrary target namespace that is different from any namespace actually used by the application, and it contains xs:import elements corresponding one-for-one with the xsl:import-schema declarations in the stylesheet, with the following correspondence:
The namespace attribute of the xs:import element is copied from the namespace attribute of the xsl:import-schema declaration if it is explicitly present, or is implied by the targetNamespace attribute of a contained xs:schema element, and is absent if it is absent.
The schemaLocation attribute of the xs:import element is copied from the schema-location attribute of the xsl:import-schema declaration if present, and is absent if it is absent. If there is a contained xs:schema element, the effective value of the schemaLocation attribute is a URI referencing a document containing a copy of the xs:schema element.
The base URI of the xs:import element is the same as the base URI of the xsl:import-schema declaration.
The schema components included in the in-scope schema components (that is, the components whose names are available for use within the stylesheet) are the top-level element and attribute declarations and type definitions that are available for reference within the synthetic schema document. See [XML Schema Part 1] (section 4.2.3, References to schema components across namespaces).
[ERR XTSE0220] It is a static error if the synthetic schema document does not satisfy the constraints described in [XML Schema Part 1] (section 5.1, Errors in Schema Construction and Structure). This includes, without loss of generality, conflicts such as multiple definitions of the same name.
Note:
The synthetic schema document does not need to be constructed by a real implementation. It is purely a mechanism for defining the semantics of xsl:import-schema in terms of rules that already exist within the XML Schema specification. In particular, it implicitly defines the rules that determine whether the set of xsl:import-schema declarations are mutually consistent.
These rules do not cause names to be imported transitively. The fact that a name is available for reference within a schema document A does not of itself make the name available for reference in a stylesheet that imports the target namespace of schema document A. (See [XML Schema Part 1] section 3.15.3, Constraints on XML Representations of Schemas.) The stylesheet must import all the namespaces containing names that it actually references.
The namespace attribute indicates that a schema for the given namespace is required by the stylesheet. This information may be enough on its own to enable an implementation to locate the required schema components. The namespace attribute may be omitted to indicate that a schema for names in no namespace is being imported. The zero-length string is not a valid namespace URI, and is therefore not a valid value for the namespace attribute.
The schema-location attribute is a URI Reference that gives a hint indicating where a schema document or other resource containing the required definitions may be found. It is likely that a schema-aware XSLT processor will be able to process a schema document found at this location.
The XML Schema specification gives implementations flexibility in how to handle multiple imports for the same namespace. Multiple imports do not cause errors if the definitions do not conflict.
A consequence of these rules is that it is not intrinsically an error if no schema document can be located for a namespace identified in an xsl:import-schema declaration. This will cause an error only if it results in the stylesheet containing references to names that have not been imported.
An inline schema document (using an xs:schema element as a child of the xsl:import-schema element) has the same status as an external schema document, in the sense that it acts as a hint for a source of schema components in the relevant namespace. To ensure that the inline schema document is always used, it is advisable to use a target namespace that is unique to this schema document.
The use of a namespace in an xsl:import-schema declaration does not by itself associate any namespace prefix with the namespace. If names from the namespace are used within the stylesheet module then a namespace declaration must be included in the stylesheet module, in the usual way.
The following example shows an inline schema document. This declares a simple type local:yes-no, which the stylesheet then uses in the declaration of a variable.
The example assumes the namespace declaration xmlns:local="http://example.com/ns/yes-no"
<xsl:import-schema> <xs:schema targetNamespace="http://example.com/ns/yes-no" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:local="http://example.com/ns/yes-no"> <xs:simpleType name="yes-no"> <xs:restriction base="xs:string"> <xs:enumeration value="yes"/> <xs:enumeration value="no"/> </xs:restriction> </xs:simpleType> </xs:schema> </xsl:import-schema> <xsl:variable name="condition" select="local:yes-no('yes')" as="local:yes-no"/>
There are two built-in functions (analyze-string and json-to-xml) whose result is an XML structure for which a schema is defined. The namespace for these schema definitions is (in both cases) http://www.w3.org/2005/xpath-functions. Schema components for these namespaces are available for reference within the stylesheet if and only if an xsl:import-schema declaration is present referencing this namespace. If such a declaration is present, then the schema that is imported is the schema defined in the specification of these functions: the schemaLocation attribute has no effect.
The data model used by XSLT is the XPath 3.0 and XQuery 3.0 data model (XDM), as defined in [XDM 3.0]. XSLT operates on source, result and stylesheet documents using the same data model.
This section elaborates on some particular features of XDM as it is used by XSLT:
The rules in 3.13.1 Stripping Whitespace and Commentary from the Stylesheet and 4.3.2 Stripping Whitespace from a Source Tree make use of the concept of a whitespace text node.
[Definition: A whitespace text node is a text node whose content consists entirely of whitespace characters (that is, U+0009 (TAB) , U+000A (NEWLINE) , U+000D (CARRIAGE RETURN) , or U+0020 (SPACE) ).]
Note:
Features of a source XML document that are not represented in the XDM tree will have no effect on the operation of an XSLT stylesheet. Examples of such features are entity references, CDATA sections, character references, whitespace within element tags, and the choice of single or double quotes around attribute values.
The XDM data model defined in [XDM 3.0] is capable of representing either an XML 1.0 document (conforming to [XML 1.0] and [Namespaces in XML]) or an XML 1.1 document (conforming to [XML 1.1] and [Namespaces in XML 1.1]), and it makes no distinction between the two. In principle, therefore, XSLT 4.0 can be used with either of these XML versions.
Construction of the XDM tree is outside the scope of this specification, so XSLT 4.0 places no formal requirements on an XSLT processor to accept input from either XML 1.0 documents or XML 1.1 documents or both. This specification does define a serialization capability (see 2726 Serialization), though from a conformance point of view it is an optional feature. Although facilities are described for serializing the XDM tree as either XML 1.0 or XML 1.1 (and controlling the choice), there is again no formal requirement on an XSLT processor to support either or both of these XML versions as serialization targets.
Because the XDM tree is the same whether the original document was XML 1.0 or XML 1.1, the semantics of XSLT processing do not depend on the version of XML used by the original document. There is no reason in principle why all the input and output documents used in a single transformation must conform to the same version of XML.
Some of the syntactic constructs in XSLT 4.0 and XPath 3.0, for example the productions CharXML and NCNameNames, are defined by reference to the XML and XML Namespaces specifications. There are slight variations between the XML 1.0 and XML 1.1 versions of these productions (and, indeed, between different editions of XML 1.0). Implementations may support any version; it is recommended that an XSLT 4.0 processor that implements the 1.1 versions should also provide a mode that supports the 1.0 versions. It is thus implementation-defined which versions and editions of XML and XML Namespaces are supported by the implementation.
Note:
The specification referenced as [Namespaces in XML] was actually published without a version number.
The current version of [XML Schema 1.1 Part 2] references the XML 1.1 specifications, but the previous version ([XML Schema Part 2]) (that is, XSD 1.0) remains in widespread use, and only references XML 1.0. With processors lacking support for XSD 1.1, therefore, datatypes such as xs:NCName and xs:ID may be constrained by the XML 1.0 rules, and not allow the full range of values permitted by XML 1.1. It is recommended that implementers wishing to support XML 1.1 should consult [XML Schema 1.0 and XML 1.1] for guidance.
For backwards compatibility reasons, XSLT 4.0 continues to support the disable-output-escaping feature introduced in XSLT 1.0. This is an optional feature and implementations are not required to support it. A new facility, that of named character maps (see 27.326.3 Character Maps) was introduced in XSLT 2.0. It provides similar capabilities to disable-output-escaping, but without distorting the data model.
If an implementation supports the disable-output-escaping attribute of xsl:text and xsl:value-of, (see 27.526.5 Disabling Output Escaping), then the data model for trees constructed by the processor is augmented with a boolean value representing the value of this property. This boolean value, however, can be set only within a final result tree that is being passed to the serializer.
Conceptually, each character in a text node on such a result tree has a boolean property indicating whether the serializer is to disable the normal rules for escaping of special characters (for example, outputting of & as &) in respect of this character.
Note:
In practice, the nodes in a final result tree will often be streamed directly from the XSLT processor to the serializer. In such an implementation, disable-output-escaping can be viewed not so much a property stored with nodes in the tree, but rather as additional information passed across the interface between the XSLT processor and the serializer.
XPath defines the concept of an expression contextXP which contains all the information that can affect the result of evaluating an expression. The expression context has two parts, the static contextXP, and the dynamic contextXP. The components that make up the expression context are defined in the XPath specification (see Section 2.2 Expression ContextXP). This section describes the way in which these components are initialized when an XPath expression is contained within an XSLT stylesheet.
This section does not apply to static expressions (whose context is defined in 9.7 Static Expressions), nor to XPath expressions evaluated using xsl:evaluate (whose context is defined in 10.4.2 Dynamic context for the target expression). [XSLT 3.0 Erratum E24, bug 30241]
As well as providing values for the static and dynamic context components defined in the XPath specification, XSLT defines additional context components of its own. These context components are used by XSLT instructions (for example, xsl:next-match and xsl:apply-imports), and also by the functions in the extended function library described in this specification.
The following four sections describe:
5.3.1 Initializing the Static Context
5.3.2 Additional Static Context Components used by XSLT
5.3.3 Initializing the Dynamic Context
5.3.4 Additional Dynamic Context Components used by XSLT
The static contextXP of an XPath expression appearing in an XSLT stylesheet is initialized as follows. In these rules, the term containing element means the element within the stylesheet that is the parent of the attribute or text node whose value contains the XPath expression in question, and the term enclosing element means the containing element or any of its ancestors.
XPath 1.0 compatibility mode is set to true if and only if the containing element is processed with XSLT 1.0 behavior (see 3.9 Backwards Compatible Processing).
The statically known namespacesXP are the applicable static namespaces for the containing element.
The default namespace for elements and typesXP is determined as described in 5.1.2.1 Unprefixed Element Names.
The default function namespaceXP is http://www.w3.org/2005/xpath-functions (and cannot be changed).
The in-scope schema definitionsXP for the XPath expression are the same as the in-scope schema components for the stylesheet, and are as specified in 3.14 Built-in Types.
The in-scope variablesXP are defined by the variable binding elements that are in scope for the containing element (see 9 Variables and Parameters).
The statically known function definitionsXP are:
The functions defined in [Functions and Operators 4.0] in namespaces http://www.w3.org/2005/xpath-functions and http://www.w3.org/2005/xpath-functions/math;
The functions defined in this specification in namespaces http://www.w3.org/2005/xpath-functions and http://www.w3.org/2005/xpath-functions/map;
Constructor functions for all the simple types in the in-scope schema definitionsXP, including both built-in types and user-defined types;
The stylesheet functions defined in the containing package;
Stylesheet functions defined in used packages, subject to visibility: see 3.5.2 Dependencies between Packages;
any extension functions bound using implementation-defined mechanisms (see 2524 Extensibility and Fallback).
Note:
The term extension function includes both vendor-supplied and user-written extension functions.
Note:
It follows from the above that a conformant XSLT processor must implement the entire library of functions defined in [Functions and Operators 4.0] as well as those defined in this specification.
The statically known collationsXP are implementation-defined, except that they must always include (a) the Unicode codepoint collation, defined in Section 5.3 Comparison of stringsFO, and (b) the family of UCA collations described in 13.4 The Unicode Collation Algorithm.
Static base URI: In a conventional interpreted environment, the static base URI of an expression in the stylesheet is the base URI of the containing element in the stylesheet. The concept of the base URI of a node is defined in Section 5.2 base-uri Accessor DM30.
When stylesheets are executed in an environment where no source code is present (for example, because the code of the stylesheet has been compiled and is distributed as executable object code), it is recommended (subject to operational constraints such as security) that the static base URI used during stylesheet evaluation should be the location from which the stylesheet was loaded for execution (its “deployed location”). This means, for example, that when the doc or document functions are called with a relative URI, the required document is by default located relative to the deployed location of the stylesheet.
Whether or not the stylesheet is executed directly from source code, it is possible that no static base URI is available, for example because the code was supplied as an anonymous input stream, or because security policies are set to prevent executable code discovering the location from which it was loaded. If the static base URI is not known, the static-base-uri function returns an empty sequence, and other operations that depend on the static base URI may fail with a dynamic error.
The set of statically known decimal formatsXP is the set of decimal formats defined by xsl:decimal-format declarations in the stylesheet.
In addition to the values that make up the focus, an XSLT processor maintains a number of other dynamic context components that reflect aspects of the evaluation context. These components are fully described in the sections of the specification that maintain and use them. They are:
The current template rule, which is the template rule most recently invoked by an xsl:apply-templates, xsl:apply-imports, or xsl:next-match instruction: see 6.9 Overriding Template Rules;
The current mode, which is the mode set by the most recent call of xsl:apply-templates (for a full definition see 6.7 Modes);
The current group and current grouping key, which provide information about the collection of items currently being processed by an xsl:for-each-group instruction: see 14.2.1 fn:current-group and 14.2.2 fn:current-grouping-key;
Note:
In XSLT 3.0 the initial value of these two properties is “absent”, which means that any reference to their values causes a dynamic error. Previously, the initial value was an empty sequence.
The current merge group and current merge key, which provide information about the collection of items currently being processed by an xsl:merge instruction.
The current captured substrings: this is a sequence of strings, which is maintained when a string is matched against a regular expression using the xsl:analyze-string instruction, and which is accessible using the regex-group function: see 17.2 fn:regex-group.
The output state: this is a flag whose two possible values are final output state and temporary output state. The initial setting when the stylesheet is invoked by executing a template is final output state, and it is switched to temporary output state by instructions such as xsl:variable. For more details, see 26.225.2 Restrictions on the use of xsl:result-document.
The current output URI: this is the URI associated with the result tree to which instructions are currently writing. The current output URI is initially the same as the base output URI. During the evaluation of an xsl:result-document instruction, the current output URI is set to the absolute URI identified by the href attribute of that instruction.
The following non-normative table summarizes the initial state of each of the components in the evaluation context, and the instructions which cause the state of the component to change.
[Definition: The initial setting of a component of the dynamic context is used when evaluating global variables and stylesheet parameters, when evaluating the use and match attributes of xsl:key, and when evaluating the initial-value of xsl:accumulator and the select expressions or contained sequence constructors of xsl:accumulator-rule].
[Definition: The term non-contextual function call is used to refer to function calls that do not pass the dynamic context to the called function. This includes all calls on stylesheet functions and all dynamic function invocationsXP, (that is calls to function items as permitted by XPath 3.0). It excludes calls to some functions in the namespace http://www.w3.org/2005/xpath-functions, in particular those that explicitly depend on the context, such as the current-group and regex-group functions. It is implementation-defined whether, and under what circumstances, calls to extension functions are non-contextual.]
Named function references (such as position#0) and calls on function-lookup (for example, function-lookup("position", 0)) are defined to retain the XPath static and dynamic context at the point of invocation as part of the closure of the resulting function item, and to use this preserved context when a dynamic function call is subsequently made using the function item. This rule does not extend to the XSLT extensions to the dynamic context defined in this section. If a dynamic function call is made that depends on the XSLT part of the dynamic context (for example, regex-group#1(2)), then the relevant components of the context are cleared as described in the table above.
In XSLT 4.0, patterns can match any kind of item: atomic items and function items as well as nodes.
A template rule identifies the items to which it applies by means of a pattern. As well as being used in template rules, patterns are used for numbering (see 12 Numbering), for grouping (see 14 Grouping), and for declaring keys (see 20.2 Keys).
[Definition: A pattern specifies a set of conditions on an item. An item that satisfies the conditions matches the pattern; an item that does not satisfy the conditions does not match the pattern.]
There are three kinds of pattern: predicate patterns, type patterns, and node patterns:
[Definition: A predicate pattern is written as . (dot) followed by zero or more predicates in square brackets, and it matches any item for which each of the predicates evaluates to true.]
A predicate pattern .[P1][P2]... can be regarded as an abbreviation for the type pattern type(item())[P1][P2]....
The detailed semantics are given in 5.4.2.1 Predicate Patterns. This construct can be used to match items of any kind (nodes, atomic items, and function items). For example, the pattern .[starts-with(., '$')] matches any string that starts with the character $, or a node whose atomized value starts with $. This example shows a predicate pattern with a single predicate, but the grammar allows any number of predicates (zero or more).
[Definition: A type pattern can be written as type(T) (where T is an ItemTypeXP followed by zero or more predicates in square brackets, and it matches any item of type T which each of the predicates evaluates to true.]
The parameter T can also be a list of item types, separated by "|". For example, type(array(*) | map(*)) matches arrays and maps, while type(text() | comment()) matches text nodes and comment nodes.
The most commonly used type patterns can be abbreviated. For example, match="type(record(F1, F2, *))" can be abbrevated to match="record(F1, F2, *)", and match="type(array(xs:string))" can be abbreviated to match="array(xs:string)". The main case where such abbreviation is not possible is with atomic items: match="type(xs:date)" cannot be abbreviated because a bare QName is interpreted as a node pattern, matching elements named xs:date. The pattern match="type(text() | comment())" has almost the same effect as match="text() | comment()", except that the rules for calculating a default priority are different.
[Definition: A node pattern uses a subset of the syntax for path expressions, and is defined to match a node if the corresponding path expression would select the node. Node patterns may also be formed by combining other patterns using union, intersection, and difference operators.]
The syntax for node patterns (UnionExprP in the grammar: see 5.4.2 Syntax of Patterns) is a subset of the syntax for expressions. Node patterns are used only for matching nodes; an item other than a node will never match a node pattern. As explained in detail below, a node matches a node pattern if the node can be selected by deriving an equivalent expression, and evaluating this expression with respect to some possible context.
Note:
The specification uses the phrases an item matches a pattern and a pattern matches an item interchangeably. They are equivalent: an item matches a pattern if and only if the pattern matches the item.
[ERR XTSE0340] Where an attribute is defined to contain a pattern, it is a static error if the pattern does not match the production Pattern40.
The complete grammar for patterns is listed in FE Pattern Syntax Summary. It uses the notation defined in Section A.1.1 NotationXP.
The lexical rules for patterns are the same as the lexical rules for XPath expressions, as defined in Section A.3 Lexical structureXP. Comments are permitted between tokens, using the syntax (: ... :). All other provisions of the XPath grammar apply where relevant, for example the rules for whitespace handling and extra-grammatical constraints.
Pattern40 | ::= | PredicatePattern | TypePattern | NodePattern |
PredicatePattern | ::= | "." PredicateXP* |
TypePattern | ::= | (WrappedItemTest | AnyItemTestXP | FunctionTypeXP | MapTypeXP | ArrayTypeXP | RecordTypeXP | EnumerationTypeXP) PredicateXP* |
NodePattern | ::= | UnionExprP |
Patterns fall into three groups:
A PredicatePattern matches items according to conditions that the item must satisfy: for example .[. castable as xs:integer] matches any value (it might be an atomic item, a node, or an array) that is castable as an integer.
A TypePattern matches items according to their type. For example type(xs:integer) matches an atomic item that is an instance of xs:integer, while record(longitude, latitude) matches a map that has exactly two entries, with keys "longitude" and "latitude"
A NodePattern matches nodes in a tree, typically by specifying a path that can be used to locate the nodes: for example order matches an element node named order, while billing-address/city matches an element named city whose parent node is an element named billing-address.
The following sections define the rules for each of these groups.
[Definition: 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, atomic items, and function items. The way that the resulting sequence is used depends on the containing instruction.]
Many XSLT elements, and also literal result elements, are defined to take a sequence constructor as their content.
Four kinds of nodes may be encountered in a sequence constructor:
A Text node appearing in the stylesheet (if it has not been removed in the process of whitespace stripping: see 3.13.1 Stripping Whitespace and Commentary from the Stylesheet) is processed as follows:
if the effective value of the standard attribute [xsl:]expand-text is no, or in the absence of this attribute, the text node in the stylesheet is copied to create a new parentless text node in the result of the sequence constructor.
Otherwise (the effective value of [xsl:]expand-text is yes), the text node in the stylesheet is processed as described in 5.7.2 Text Value Templates.
A literal result element is evaluated to create a new parentless element node, having the same expanded QName as the literal result element: see 11.1 Literal Result Elements.
An XSLT instruction produces a sequence of zero, one, or more items as its result. For most XSLT instructions, these items are nodes, but some instructions (such as xsl:sequence and xsl:copy-of) can also produce atomic items or function items. Several instructions, such as xsl:element, return a newly constructed parentless node (which may have its own attributes, namespaces, children, and other descendants). Other instructions, such as xsl:if, pass on the items produced by their own nested sequence constructors. The xsl:sequence instruction may return atomic items, function items, or existing nodes.
An extension instruction (see 25.224.2 Extension Instructions) also produces a sequence of items as its result.
[Definition: The result of evaluating a sequence constructor is the sequence of items formed by concatenating the results of evaluating each of the nodes in the sequence constructor, retaining order. This is referred to as the immediate result of the sequence constructor.]
However:
For the effect of the xsl:fallback instruction, see 25.2.324.2.3 Fallback.
For the effect of the xsl:on-empty and xsl:on-non-empty instructions, see 8.5 Conditional Content Construction.
The way that immediate result of a sequence constructor is used depends on the containing element in the stylesheet, and is specified in the rules for that element. It is typically one of the following:
The immediate result may be bound to a variable or delivered as the result of a stylesheet function. In this case the as attribute of the containing xsl:variable or xsl:function element may be used to declare its required type, and the immediate result is then converted to the required type by applying the coercion rules.
Note:
In the absence of an as attribute, the result of a function is the immediate result of the sequence constructor; but the value of a variable (for backwards compatibility reasons) is a document node whose content is formed by applying the rules in 5.8.1 Constructing Complex Content to the immediate result.
The coercion rules do not merge adjacent text nodes or insert separators between adjacent items. This means it is often inappropriate to use xsl:value-of in the body of xsl:variable or xsl:function, especially when the intent is to return an atomic result. The xsl:sequence instruction is designed for this purpose, and is usually a better choice.
The result of a function, or the value of a variable, may contain nodes (such as elements, attributes, and text nodes) that are not attached to any parent node in a result tree. The semantics of XPath expressions when applied to parentless nodes are well-defined; however, such expressions should be used with care. For example, the expression / causes a type error if the root of the tree containing the context node is not a document node.
Parentless attribute nodes require particular care because they have no namespace nodes associated with them. A parentless attribute node is not permitted to contain namespace-sensitive content (for example, a QName or an XPath expression) because there is no information enabling the prefix to be resolved to a namespace URI. Parentless attributes can be useful in an application (for example, they provide an alternative to the use of attribute sets: see 10.2 Named Attribute Sets) but they need to be handled with care.
The sequence may be returned as the result of the containing element. This happens, for example, when the element containing the sequence constructor is xsl:break, xsl:catch, xsl:fallback, xsl:for-each, xsl:for-each-group, xsl:fork, xsl:if, xsl:iterate, xsl:matching-substring, xsl:non-matching-substring, xsl:on-completion, xsl:otherwise, xsl:perform-sort, xsl:sequence, xsl:try, or xsl:when.
The sequence may be used to construct the content of a new element or document node. This happens when the sequence constructor appears as the content of a literal result element, or of one of the instructions xsl:copy, xsl:element, xsl:document, xsl:result-document, xsl:assert, or xsl:message. It also happens when the sequence constructor is contained in one of the elements xsl:variable, xsl:param, or xsl:with-param, when this instruction has no as attribute. For details, see 5.8.1 Constructing Complex Content.
The sequence may be used to construct the string value of an attribute node, text node, namespace node, comment node, or processing instruction node. This happens when the sequence constructor is contained in one of the elements xsl:attribute, xsl:value-of, xsl:namespace, xsl:comment, or xsl:processing-instruction. For details, see 5.8.2 Constructing Simple Content.
This section describes three constructs that can be used to provide subroutine-like functionality that can be invoked from anywhere in the stylesheet: named templates (see 10.1 Named Templates), named attribute sets (see 10.2 Named Attribute Sets), and stylesheet functions (see 10.3 Stylesheet Functions).
[Definition: The following constructs are classified as invocation constructs: the instructions xsl:call-template, xsl:apply-templates, xsl:apply-imports, and xsl:next-match; XPath function calls that bind to stylesheet functions; XPath dynamic function calls; the functions accumulator-before and accumulator-after; the [xsl:]use-attribute-sets attribute. These all have the characteristic that they can cause evaluation of constructs that are not lexically contained within the calling construct.]
<!-- Category: instruction -->
<xsl:evaluate
xpath = expression
as? = sequence-type〔'item()*'〕
base-uri? = { uri }
with-params? = expression
context-item? = expression
namespace-context? = expression
schema-aware? = { boolean }〔'no'〕 >
<!-- Content: (xsl:with-param | xsl:fallback)* -->
</xsl:evaluate>
The xsl:evaluate instruction constructs an XPath expression in the form of a string, evaluates the expression in a specified context, and returns the result of the evaluation.
The expression given as the value of the xpath attribute is evaluated and the result is converted to a string using the coercion rules.
[Definition: The string that results from evaluating the expression in the xpath attribute is referred to as the target expression.]
[ERR XTDE3160] It is a dynamic error if the target expression is not a valid expression (that is, if a static error occurs when analyzing the string according to the rules of the XPath specification).
The as attribute, if present, indicates the required type of the result. If the attribute is absent, the required type is item()*, which allows any result. The result of evaluating the target expression is converted to the required type using the coercion rules. This may cause a type error if conversion is not possible. The result after conversion is returned as the result of the xsl:evaluate instruction.
The target expression may contain variable references; the values of such variables may be supplied using an xsl:with-param child instruction if the names of the variables are known statically, or using a map supplied as the value of the expression in the with-params attribute if the names are only known dynamically. If the with-params attribute is present then it must contain an expression whose value, when evaluated, is of type map(xs:QName, item()*) (see 21 Maps for details of maps).
[ERR XTTE3165] It is a type error if the result of evaluating the expression in the with-params attribute of the xsl:evaluate instruction is anything other than a single map of type map(xs:QName, item()*).
The static contextXP for the target expression is as follows:
XPath 1.0 compatibility mode is false.
Statically known namespaces and default namespaces for elements and for types:
if the namespace-context attribute is present, then its value is an expression whose required type is a single node. The expression is evaluated, and the in-scope namespaces of the resulting node are used as the statically known namespaces for the target expression. The binding for the default namespace in the in-scope namespaces is used as the default namespace for both elements and types in the target expression.
[ERR XTTE3170] It is a type error if the result of evaluating the namespace-context attribute of the xsl:evaluate instruction is anything other than a single node.
if the namespace-context attribute is absent, then the applicable static namespaces of the xsl:evaluate instruction (with the exception of any binding for the default namespace) are used as the statically known namespaces for the target expression, and the value of the attribute [xsl:]xpath-default-namespace, if present, is used to establish the default namespace for elements and types in the target expression, as described in 5.1.2 Unprefixed Lexical QNames in Expressions and Patterns.
Note:
XPath 3.0 allows expanded names to be written in a context-independent way using the syntax Q{namespace-uri}local-name
Default function namespace: the standard function namespace.
In-scope schema definitions: if the schema-aware attribute is present and has the effective valueyes, then the in-scope schema definitions from the stylesheet context (that is, the schema definitions imported using xsl:import-schema). Otherwise, the built-in types (see 3.14 Built-in Types).
In-scope variables: the names of the in-scope variables are the union of the names appearing in the name attribute of the contained xsl:with-param elements, and the names present as keys in the map obtained by evaluating the with-params attribute, if present. The corresponding type is item()* in the case of a name found as a key in the with-params map, or the type named in the as attribute of xsl:with-param child (defaulting to item()*) otherwise.
If a variable name is present both the static xsl:with-param children and also in the dynamic with-params map, the value from the latter takes precedence.
Note:
Variables declared in the stylesheet in xsl:variable or xsl:param elements are not in-scope within the target expression.
Function signatures:
All functions defined in [Functions and Operators 4.0] in the fn and math, map, and array namespaces;
Constructor functions for named simple types included in the in-scope schema definitions;
All user-defined functions present in the containing package provided their visibility is not hidden or private;
An implementation-defined set of extension functions.
Note that this set deliberately excludes XSLT-defined functions in the standard function namespace including for example, key, current-group, and system-property. A list of these functions is in HG.2 List of XSLT-defined functions.
Statically known collations: the same as the collations available at this point in the stylesheet.
Default collation: the same as the default collation defined at this point in the stylesheet (for example, by use of the [xsl:]default-collation attribute)
Base URI: if the base-uri attribute is present, then its effective value; otherwise, the base URI of the xsl:evaluate instruction.
Statically known documents: the empty set
Statically known collections: the empty set
Statically known default collection type: node()*
xsl:evaluate as an optional featureThe xsl:evaluate instruction was first introduced in XSLT 3.0. It is part of the dynamic evaluation feature, which is an optional feature of the specification (see 28.627.6 Dynamic Evaluation Feature). An XSLT 4.0 processor may disable the feature, or allow users to disable the feature. The processor may be able to determine during static analysis whether or not the feature is available, or it may only be able to determine this during dynamic evaluation. In the first case we refer to the feature being statically disabled, in the second case to it being dynamically disabled.
If the feature is statically disabled, then:
A call to element-available('xsl:evaluate') returns false, wherever it appears;
A call to system-property('xsl:supports-dynamic-evaluation') returns the string "no", wherever it appears;
If an xsl:evaluate instruction has an xsl:fallback child, fallback processing takes place;
No static error is raised if an xsl:evaluate instruction is present in the stylesheet (an error occurs only if it is actually evaluated).
If the feature is dynamically disabled, then:
A call to element-available('xsl:evaluate') appearing in a static expression (for example, in an [xsl:]use-when attribute) returns true;
A call to element-available('xsl:evaluate') appearing anywhere else returns false;
A call to system-property('xsl:supports-dynamic-evaluation') appearing in a static expression (for example, in an [xsl:]use-when attribute) returns the string "yes";
A call to system-property('xsl:supports-dynamic-evaluation') appearing anywhere else returns the string "no";
If an xsl:evaluate instruction has an xsl:fallback child, fallback processing takes place;
In the absence of an xsl:fallback child, a dynamic error is raised if an xsl:evaluate instruction is evaluated. The dynamic error may be caught using xsl:try and xsl:catch.
If a processor supports the dynamic evaluation feature, it is implementation-defined how the processor allows users to disable dynamic evaluation and it is implementation-defined whether the mechanism is static or dynamic.
[ERR XTDE3175] It is a dynamic error if an xsl:evaluate instruction is evaluated when use of xsl:evaluate has been statically or dynamically disabled.
In consequence of these rules, the recommended approach for stylesheet authors to write code that works whether or not xsl:evaluate is enabled is to use an xsl:fallback child instruction. For example:
<xsl:variable name="isValid" as="xs:boolean"> <xsl:evaluate xpath="$validityCondition"> <xsl:fallback><xsl:sequence select="true()"/></xsl:fallback> </xsl:evaluate> </xsl:variable>
Note:
There may be circumstances where it is inappropriate to allow use of xsl:evaluate. For example:
There may be security risks associated with the ability to execute code from an untrusted source, which cannot be inspected during static analysis.
There may be environments where the available computing resources are sufficient to enable pre-compiled stylesheets to be executed, but not to enable XPath expressions to be compiled into executable code.
Processors that implement xsl:evaluate should provide mechanisms allowing calls on xsl:evaluate to be disabled. Implementations may disable the feature by default, and they may disable it unconditionally.
This section describes instructions that directly create new nodes, or sequences of nodes, atomic items, and/or function items.
[Definition: 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 25.224.2 Extension Instructions) is classified as a literal result element.] A literal result element is evaluated to construct a new element node with the same expanded QName (that is, the same namespace URI, local name, and namespace prefix). The result of evaluating a literal result element is a node sequence containing one element, the newly constructed element node.
The content of the element is a sequence constructor (see 5.8 Sequence Constructors). The sequence obtained by evaluating this sequence constructor, after prepending any attribute nodes produced as described in 11.1.2 Attribute Nodes for Literal Result Elements and namespace nodes produced as described in 11.1.3 Namespace Nodes for Literal Result Elements, is used to construct the content of the element, following the rules in 5.8.1 Constructing Complex Content
The base URI of the new element is copied from the base URI of the literal result element in the stylesheet, unless the content of the new element includes an xml:base attribute, in which case the base URI of the new element is the value of that attribute, resolved (if it is a relative URI reference) against the base URI of the literal result element in the stylesheet. (Note, however, that this is only relevant when creating a parentless element. When the literal result element is copied to form a child of an element or document node, the base URI of the new copy is taken from that of its new parent.)
The attributes xsl:type and xsl:validation may be used on a literal result element to invoke validation of the contents of the element against a type definition or element declaration in a schema, and to determine the type annotation that the new element node will carry. These attributes also affect the type annotation carried by any elements and attributes that have the new element node as an ancestor. These two attributes are both optional, and if one is specified then the other must be omitted.
The value of the xsl:validation attribute, if present, must be one of the values strict, lax, preserve, or strip. The value of the xsl:type attribute, if present, must be an EQName identifying a type definition that is present in the in-scope schema components for the stylesheet. Neither attribute may be specified as an attribute value template. The effect of these attributes is described in 26.425.4 Validation.
The created element node will have a copy of the namespace nodes that were present on the element node in the stylesheet tree with the exception of any namespace node whose string value is designated as an excluded namespace. Special considerations apply to aliased namespaces: see 11.1.4 Namespace Aliasing.
The following namespaces are designated as excluded namespaces:
The XSLT namespace URI (http://www.w3.org/1999/XSL/Transform)
A namespace URI declared as an extension namespace (see 25.224.2 Extension Instructions)
A namespace URI designated by using an [xsl:]exclude-result-prefixes attribute either on the literal result element itself or on an ancestor element. The attribute must be in the XSLT namespace only if its parent element is not in the XSLT namespace.
The value of the attribute is either #all, or a whitespace-separated list of tokens, each of which is either a namespace prefix or #default. The namespace bound to each of the prefixes is designated as an excluded namespace.
[ERR XTSE0808] It is a static error if a namespace prefix is used within the [xsl:]exclude-result-prefixes attribute and there is no namespace binding in scope for that prefix.
Note:
The prefix must be declared in a native namespace binding, not in a fixed namespace binding.
The default namespace of the parent element of the [xsl:]exclude-result-prefixes attribute (see Section 6.2 Element Nodes DM30) may be designated as an excluded namespace by including #default in the list of namespace prefixes.
[ERR XTSE0809] It is a static error if the value #default is used within the [xsl:]exclude-result-prefixes attribute and the parent element of the [xsl:]exclude-result-prefixes attribute has no default namespace.
The value #all indicates that all namespaces that are in scope for the stylesheet element that is the parent of the [xsl:]exclude-result-prefixes attribute are designated as excluded namespaces.
The designation of a namespace as an excluded namespace is effective within the subtree of the stylesheet module rooted at the element bearing the [xsl:]exclude-result-prefixes attribute; a subtree rooted at an xsl:stylesheet element does not include any stylesheet modules imported or included by children of that xsl:stylesheet element.
The excluded namespaces, as described above, only affect namespace nodes copied from the stylesheet when processing a literal result element. There is no guarantee that an excluded namespace will not appear on the result tree for some other reason. Namespace nodes are also written to the result tree as part of the process of namespace fixup (see 5.8.3 Namespace Fixup), or as the result of instructions such as xsl:copy and xsl:element.
Note:
When a stylesheet uses a namespace declaration only for the purposes of addressing a source tree, specifying the prefix in the [xsl:]exclude-result-prefixes attribute will avoid superfluous namespace declarations in the serialized result tree. The attribute is also useful to prevent namespaces used solely for the naming of stylesheet functions or extension functions from appearing in the serialized result tree.
In XSLT 4.0, a simpler approach is to declare such namespaces in a fixed-namespaces attribute on the xsl:stylesheet element: see 3.7.1 The fixed-namespaces Attribute. Namespace prefixes declared in that way are not eligible to be used in the names of literal result elements and their attributes, and they are not copied into the result tree.
Consider the following stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="a.uri" xmlns:b="b.uri" exclude-result-prefixes="#all"> <xsl:template match="/"> <foo xmlns:c="c.uri" xmlns:d="d.uri" xmlns:a2="a.uri" xsl:exclude-result-prefixes="c"/> </xsl:template> </xsl:stylesheet>
The result of this stylesheet will be:
<foo xmlns:d="d.uri"/>
The namespaces a.uri and b.uri are excluded by virtue of the exclude-result-prefixes attribute on the xsl:stylesheet element, and the namespace c.uri is excluded by virtue of the xsl:exclude-result-prefixes attribute on the foo element. The setting #all does not affect the namespace d.uri because d.uri is not an in-scope namespace for the xsl:stylesheet element. The element in the result tree does not have a namespace node corresponding to xmlns:a2="a.uri" because the effect of exclude-result-prefixes is to designate the namespace URI a.uri as an excluded namespace, irrespective of how many prefixes are bound to this namespace URI.
If the stylesheet is changed so that the literal result element has an attribute b:bar="3", then the element in the result tree will typically have a namespace declaration xmlns:b="b.uri" (the processor may choose a different namespace prefix if this is necessary to avoid conflicts). The exclude-result-prefixes attribute makes b.uri an excluded namespace, so the namespace node is not automatically copied from the stylesheet, but the presence of an attribute whose name is in the namespace b.uri forces the namespace fixup process (see 5.8.3 Namespace Fixup) to introduce a namespace node for this namespace.
A literal result element may have an optional xsl:inherit-namespaces attribute, with the value yes or no. The default value is yes. If the value is set to yes, or is omitted, then the namespace nodes created for the newly constructed element are copied to the children and descendants of the newly constructed element, as described in 5.8.1 Constructing Complex Content. If the value is set to no, then these namespace nodes are not automatically copied to the children. This may result in namespace undeclarations (such as xmlns="" or, in the case of XML 1.1, xmlns:p="") appearing on the child elements when they are serialized.
xsl:element<!-- Category: instruction -->
<xsl:element
name = { qname }
namespace? = { uri }
inherit-namespaces? = boolean〔'yes'〕
use-attribute-sets? = eqnames〔''〕
type? = eqname
validation? = "strict" | "lax" | "preserve" | "strip" >
<!-- Content: sequence-constructor -->
</xsl:element>
The xsl:element instruction allows an element to be created with a computed name. The expanded QName of the element to be created is specified by a requiredname attribute and an optional namespace attribute.
The result of evaluating the xsl:element instruction, in usual circumstances, is the newly constructed element node.
The xsl:element instruction has an optional inherit-namespaces attribute, with the value yes or no. The default value is yes. If the value is set to yes, or is omitted, then the namespace nodes created for the newly constructed element (whether these were copied from those of the source node, or generated as a result of namespace fixup) are copied to the children and descendants of the newly constructed element, as described in 5.8.1 Constructing Complex Content. If the value is set to no, then these namespace nodes are not automatically copied to the children. This may result in namespace undeclarations (such as xmlns="" or, in the case of XML Namespaces 1.1, xmlns:p="") appearing on the child elements when the element is serialized.
The base URI of the new element is copied from the base URI of the xsl:element instruction in the stylesheet, unless the content of the new element includes an xml:base attribute, in which case the base URI of the new element is the value of that attribute, resolved (if it is a relative URI) against the base URI of the xsl:element instruction in the stylesheet. (Note, however, that this is only relevant when creating parentless elements. When the new element is copied to form a child of an element or document node, the base URI of the new copy is taken from that of its new parent.)
The values of the nilled, is-id, and is-idrefs properties of the new element depend on the type and validation attributes of the xsl:element instruction, as explained in 26.425.4 Validation.
The optional attributes type and validation may be used on the xsl:element instruction to invoke validation of the contents of the element against a type definition or element declaration in a schema, and to determine the type annotation that the new element node will carry. These attributes also affect the type annotation carried by any elements and attributes that have the new element node as an ancestor. These two attributes are both optional, and if one is specified then the other must be omitted. The permitted values of these attributes and their semantics are described in 26.425.4 Validation.
Note:
The final type annotation of the element in the result tree also depends on the type and validation attributes of the instructions used to create the ancestors of the element.
xsl:attribute<!-- Category: instruction -->
<xsl:attribute
name = { qname }
namespace? = { uri }
select? = expression
separator? = { string }
type? = eqname
validation? = "strict" | "lax" | "preserve" | "strip" >
<!-- Content: sequence-constructor -->
</xsl:attribute>
The xsl:attribute element can be used to add attributes to result elements whether created by literal result elements in the stylesheet or by instructions such as xsl:element or xsl:copy. The expanded QName of the attribute to be created is specified by a requiredname attribute and an optional namespace attribute. Except in error cases, the result of evaluating an xsl:attribute instruction is the newly constructed attribute node.
The string value of the new attribute node may be defined either by using the select attribute, or by the sequence constructor that forms the content of the xsl:attribute element. These are mutually exclusive: if the select attribute is present then the sequence constructor must be empty, and if the sequence constructor is non-empty then the select attribute must be absent. If the select attribute is absent and the sequence constructor is empty, then the string value of the new attribute node will be a zero-length string. The way in which the value is constructed is specified in 5.8.2 Constructing Simple Content.
[ERR XTSE0840] It is a static error if the select attribute of the xsl:attribute element is present unless the element has empty content.
If the separator attribute is present, then the effective value of this attribute is used to separate adjacent items in the result sequence, as described in 5.8.2 Constructing Simple Content. In the absence of this attribute, the default separator is U+0020 (SPACE) when the content is specified using the select attribute, or a zero-length string when the content is specified using a sequence constructor.
The name attribute is interpreted as an attribute value template, whose effective valuemust be a lexical QName.
[ERR XTDE0850] It is a dynamic error if the effective value of the name attribute is not a lexical QName.
[ERR XTDE0855] In the case of an xsl:attribute instruction with no namespace attribute, it is a dynamic error if the effective value of the name attribute is the string xmlns.
[ERR XTDE0860] In the case of an xsl:attribute instruction with no namespace attribute, it is a dynamic error if the effective value of the name attribute is a lexical QName whose prefix is not declared in the applicable static namespaces for the xsl:attribute instruction.
Note:
If a fixed-namespaces attribute is present on the containing xsl:stylesheet or xsl:package element, then the prefix must be declared in that attribute, not in a native namespace binding.
If the namespace attribute is not present, then the lexical QName is expanded into an expanded QName using the namespace declarations in effect for the xsl:attribute element, not including any default namespace declaration.
If the namespace attribute is present, then it too is interpreted as an attribute value template. The effective valuemust be in the lexical space of the xs:anyURI type. If the string is zero-length, then the expanded QName of the attribute has a null namespace URI. Otherwise, the string is used as the namespace URI of the expanded QName of the attribute to be created. The local part of the lexical QName specified by the name attribute is used as the local part of the expanded QName of the attribute to be created.
[ERR XTDE0865] It is a dynamic error if the effective value of the namespace attribute is not in the lexical space of the xs:anyURI datatype or if it is the string http://www.w3.org/2000/xmlns/.
Note:
The same considerations apply as for elements: [see ERR XTDE0835] in 11.2 Creating Element Nodes Using xsl:element .
The prefix of the lexical QName specified in the name attribute (or the absence of a prefix) is copied to the prefix part of the expanded QName representing the name of the new attribute node. In the event of a conflict this prefix may subsequently be added, changed, or removed during the namespace fixup process (see 5.8.3 Namespace Fixup). If the attribute is in a non-null namespace and no prefix is specified, then the namespace fixup process will invent a prefix. The term conflict here means any violation of the constraints defined in [XDM 3.0], for example the use of the same prefix to refer to two different namespaces in the element and in one of its attributes, the use of the prefix xml to refer to a namespace other than the XML namespace, or any use of the prefix xmlns.
If the name of a constructed attribute is xml:id, the processor must perform attribute value normalization by effectively applying the normalize-space function to the value of the attribute, and the resulting attribute node must be given the is-id property. This applies whether the attribute is constructed using the xsl:attribute instruction or whether it is constructed using an attribute of a literal result element. This does not imply any constraints on the value of the attribute, or on its uniqueness, and it does not affect the type annotation of the attribute, unless the containing document is validated.
Note:
The effect of setting the is-id property is that the parent element can be located within the containing document by use of the id function. In effect, XSLT when constructing a document performs some of the functions of an xml:id processor, as defined in [xml:id]; the other aspects of xml:id processing are performed during validation.
The following instruction creates the attribute colors="red green blue":
<xsl:attribute name="colors" select="'red', 'green', 'blue'"/>
It is not an error to write:
<xsl:attribute name="xmlns:xsl" namespace="file://some.namespace" select="'http://www.w3.org/1999/XSL/Transform'"/>
However, this will not result in the namespace declaration xmlns:xsl="http://www.w3.org/1999/XSL/Transform" being output. Instead, it will produce an attribute node with local name xsl, and with a system-allocated namespace prefix mapped to the namespace URI file://some.namespace. This is because the namespace fixup process is not allowed to use xmlns as the name of a namespace node.
As described in 5.8.1 Constructing Complex Content, in a sequence that is used to construct the content of an element, any attribute nodes must appear in the sequence before any element, text, comment, or processing instruction nodes. Where the sequence contains two or more attribute nodes with the same expanded QName, the one that comes last is the only one that takes effect.
Note:
If a collection of attributes is generated repeatedly, this can be done conveniently by using named attribute sets: see 10.2 Named Attribute Sets
The optional attributes type and validation may be used on the xsl:attribute instruction to invoke validation of the contents of the attribute against a type definition or attribute declaration in a schema, and to determine the type annotation that the new attribute node will carry. These two attributes are both optional, and if one is specified then the other must be omitted. The permitted values of these attributes and their semantics are described in 26.425.4 Validation.
The process of validation also determines the values of the is-id and is-idrefs properties on the new attribute node.
Note:
The final type annotation of the attribute in the result tree also depends on the type and validation attributes of the instructions used to create the ancestors of the attribute.
This section describes three different ways of creating text nodes: by means of literal text nodes in the stylesheet, or by using the xsl:text and xsl:value-of instructions. It is also possible to create text nodes using the xsl:number instruction described in 12 Numbering.
If and when the sequence that results from evaluating a sequence constructor is used to form the content of a node, as described in 5.8.2 Constructing Simple Content and 5.8.1 Constructing Complex Content, adjacent text nodes in the sequence are merged. Within the sequence itself, however, they exist as distinct nodes.
The following function returns a sequence of three text nodes:
<xsl:function name="f:wrap"> <xsl:param name="s"/> <xsl:text>(</xsl:text> <xsl:value-of select="$s"/> <xsl:text>)</xsl:text> </xsl:function>
When this function is called as follows:
<xsl:value-of select="f:wrap('---')"/>
the result is:
(---)
No additional spaces are inserted, because the calling xsl:value-of instruction merges adjacent text nodes before atomizing the sequence. However, the result of the instruction:
<xsl:value-of select="data(f:wrap('---'))"/>
is:
( --- )
because in this case the three text nodes are atomized to form three strings, and spaces are inserted between adjacent strings.
It is possible to construct text nodes whose string value is zero-length. A zero-length text node, when atomized, produces a zero-length string. However, zero-length text nodes are ignored when they appear in a sequence that is used to form the content of a node, as described in 5.8.1 Constructing Complex Content and 5.8.2 Constructing Simple Content.
A sequence constructor can contain text nodes. Each text node in a sequence constructor remaining after whitespace text nodes have been stripped as specified in 3.13.1 Stripping Whitespace and Commentary from the Stylesheet will construct a new text node with the same string value. The resulting text node is added to the result of the containing sequence constructor.
Text is processed at the tree level. Thus, markup of < in a template will be represented in the stylesheet tree by a text node that includes the character <. This will create a text node in the result tree that contains a < character, which will be represented by the markup < (or an equivalent character reference) when the result tree is serialized as an XML document, unless otherwise specified using character maps (see 27.326.3 Character Maps) or disable-output-escaping (see 27.526.5 Disabling Output Escaping).
xsl:text<!-- Category: instruction -->
<xsl:text
[disable-output-escaping]? = boolean〔'no'〕 >
<!-- Content: #PCDATA -->
</xsl:text>
The xsl:text element is evaluated to construct a new text node.
If the element or one of its ancestors has an [xsl:]expand-text attribute, and the nearest ancestor with such an attribute has the value yes, then any unescaped curly brackets in the value of the element indicate the presence of text value templates, which are expanded as described in 5.7.2 Text Value Templates.
In the absence of such an attribute, or if the effective value is no, the content of the xsl:text element is a single text node whose value forms the string value of the new text node. An xsl:text element may be empty, in which case the result of evaluating the instruction is a text node whose string value is the zero-length string.
The result of evaluating an xsl:text instruction is the newly constructed text node.
A text node that is an immediate child of an xsl:text instruction will not be stripped from the stylesheet tree, even if it consists entirely of whitespace (see 4.3.2 Stripping Whitespace from a Source Tree).
For the effect of the deprecateddisable-output-escaping attribute, see 27.526.5 Disabling Output Escaping
Note:
It is not always necessary to use the xsl:text instruction to write text nodes to the result tree. Literal text can be written to the result tree by including it anywhere in a sequence constructor, while computed text can be output using the xsl:value-of instruction. The principal reason for using xsl:text is that it offers improved control over whitespace handling.
xsl:value-ofWithin a sequence constructor, the xsl:value-of instruction can be used to generate computed text nodes. The xsl:value-of instruction computes the text using an expression that is specified as the value of the select attribute, or by means of contained instructions. This might, for example, extract text from a source tree or insert the value of a variable.
<!-- Category: instruction -->
<xsl:value-of
select? = expression
separator? = { string }
[disable-output-escaping]? = boolean〔'no'〕 >
<!-- Content: sequence-constructor -->
</xsl:value-of>
The xsl:value-of instruction is evaluated to construct a new text node; the result of the instruction is the newly constructed text node.
The string value of the new text node may be defined either by using the select attribute, or by the sequence constructor (see 5.8 Sequence Constructors) that forms the content of the xsl:value-of element. These are mutually exclusive: if the select attribute is present then the sequence constructor must be empty, and if the sequence constructor is non-empty then the select attribute must be absent. If the select attribute is absent and the sequence constructor is empty, then the result of the instruction is a text node whose string value is zero-length. The way in which the value is constructed is specified in 5.8.2 Constructing Simple Content.
[ERR XTSE0870] It is a static error if the select attribute of the xsl:value-of element is present when the content of the element is non-empty.
If the separator attribute is present, then the effective value of this attribute is used to separate adjacent items in the result sequence, as described in 5.8.2 Constructing Simple Content. In the absence of this attribute, the default separator is U+0020 (SPACE) when the content is specified using the select attribute, or a zero-length string when the content is specified using a sequence constructor.
Special rules apply when the instruction is processed with XSLT 1.0 behavior. If no separator attribute is present, and if the select attribute is present, then all items in the atomized result sequence other than the first are ignored.
The instruction:
<x><xsl:value-of select="1 to 4" separator="|"/></x>
produces the output:
<x>1|2|3|4</x>
Note:
The xsl:copy-of element can be used to copy a sequence of nodes to the result tree without atomization. See 11.9.2 Deep Copy.
For the effect of the deprecateddisable-output-escaping attribute, see 27.526.5 Disabling Output Escaping
<!-- Category: instruction -->
<xsl:document
validation? = "strict" | "lax" | "preserve" | "strip"
type? = eqname >
<!-- Content: sequence-constructor -->
</xsl:document>
The xsl:document instruction is used to create a new document node. The content of the xsl:document element is a sequence constructor for the children of the new document node. A document node is created, and the sequence obtained by evaluating the sequence constructor is used to construct the content of the document, as described in 5.8.1 Constructing Complex Content.
Except in error situations, the result of evaluating the xsl:document instruction is a single node, the newly constructed document node.
Note:
The new document is not serialized. To construct a document that is to form a final result rather than an intermediate result, use the xsl:result-document instruction described in 26.125.1 Creating Secondary Results.
The optional attributes type and validation may be used on the xsl:document instruction to validate the contents of the new document, and to determine the type annotation that elements and attributes within the result tree will carry. The permitted values and their semantics are described in 26.4.225.4.2 Validating Document Nodes.
The base URI of the new document node is taken from the base URI of the xsl:document instruction.
The document-uri and unparsed-entities properties of the new document node are set to empty.
The following example creates a temporary tree held in a variable. The use of an enclosed xsl:document instruction ensures that uniqueness constraints defined in the schema for the relevant elements are checked.
<xsl:variable name="tree" as="document-node()"> <xsl:document validation="strict"> <xsl:apply-templates/> </xsl:document> </xsl:variable>
<!-- Category: instruction -->
<xsl:processing-instruction
name = { ncname }
select? = expression >
<!-- Content: sequence-constructor -->
</xsl:processing-instruction>
The xsl:processing-instruction element is evaluated to create a processing instruction node.
The xsl:processing-instruction element has a requiredname attribute that specifies the name of the processing instruction node. The value of the name attribute is interpreted as an attribute value template.
The string value of the new processing-instruction node may be defined either by using the select attribute, or by the sequence constructor that forms the content of the xsl:processing-instruction element. These are mutually exclusive: if the select attribute is present then the sequence constructor must be empty, and if the sequence constructor is non-empty then the select attribute must be absent. If the select attribute is absent and the sequence constructor is empty, then the string value of the new processing-instruction node will be a zero-length string. The way in which the value is constructed is specified in 5.8.2 Constructing Simple Content.
[ERR XTSE0880] It is a static error if the select attribute of the xsl:processing-instruction element is present unless the element has empty content.
Except in error situations, the result of evaluating the xsl:processing-instruction instruction is a single node, the newly constructed processing instruction node.
This instruction:
<xsl:processing-instruction name="xml-stylesheet" select="('href="book.css"', 'type="text/css"')"/>
creates the processing instruction
<?xml-stylesheet href="book.css" type="text/css"?>
Note that the xml-stylesheet processing instruction contains pseudo-attributes in the form name="value". Although these have the same textual form as attributes in an element start tag, they are not represented as XDM attribute nodes, and cannot therefore be constructed using xsl:attribute instructions.
[ERR XTDE0890] It is a dynamic error if the effective value of the name attribute is not both an NCNameNames and a PITargetXML.
Note:
Because these rules disallow the name xml, the xsl:processing-instruction cannot be used to output an XML declaration. The xsl:output declaration should be used to control this instead (see 2726 Serialization).
If the result of evaluating the content of the xsl:processing-instruction contains the string ?>, this string is modified by inserting a space between the ? and > characters.
The base URI of the new processing-instruction is copied from the base URI of the xsl:processing-instruction element in the stylesheet. (Note, however, that this is only relevant when creating a parentless processing instruction. When the new processing instruction is copied to form a child of an element or document node, the base URI of the new copy is taken from that of its new parent.)
<!-- Category: instruction -->
<xsl:copy
select? = expression
copy-namespaces? = boolean〔'yes'〕
inherit-namespaces? = boolean〔'yes'〕
use-attribute-sets? = eqnames〔''〕
type? = eqname
validation? = "strict" | "lax" | "preserve" | "strip" >
<!-- Content: sequence-constructor -->
</xsl:copy>
The xsl:copy instruction provides a way of copying a selected item. The selected item is the item selected by evaluating the expression in the select attribute if present, or the context item otherwise. If the selected item is a node, evaluating the xsl:copy instruction constructs a copy of the selected node, and the result of the xsl:copy instruction is this newly constructed node. By default, the namespace nodes of the context node are automatically copied as well, but the attributes and children of the node are not automatically copied.
[ERR XTTE0945] It is a type error to use the xsl:copy instruction with no select attribute when the context item is absent.
If the select expression returns an empty sequence, the xsl:copy instruction returns an empty sequence, and the contained sequence constructor is not evaluated.
[ERR XTTE3180] It is a type error if the result of evaluating the select expression is a sequence of more than one item.
When the selected item is an atomic item or function item, the xsl:copy instruction returns this value. The sequence constructor is not evaluated.
When the selected item is an attribute node, text node, comment node, processing instruction node, or namespace node, the xsl:copy instruction returns a new node that is a copy of the context node. The new node will have the same node kind, name, and string value as the context node. In the case of an attribute node, it will also have the same values for the is-id and is-idrefs properties. The sequence constructor is not evaluated.
When the selected item is a document node or element node, the xsl:copy instruction returns a new node that has the same node kind and name as the selected node. The content of the new node is formed by evaluating the sequence constructor contained in the xsl:copy instruction. If the select attribute is present then the sequence constructor is evaluated with the selected item as the singleton focus; otherwise it is evaluated using the context of the xsl:copy instruction unchanged. The sequence obtained by evaluating this sequence constructor is used (after prepending any attribute nodes or namespace nodes as described in the following paragraphs) to construct the content of the document or element node, as described in 5.8.1 Constructing Complex Content.
When the selected item is a document node, the unparsed-entities property of the existing document node is copied to the new document node.
When the selected item is an element or attribute node, the values of the is-id, is-idrefs, and nilled properties of the new element or attribute depend on the values of the validation and type attributes, as defined in 26.425.4 Validation.
The xsl:copy instruction has an optional use-attribute-sets attribute, whose value is a whitespace-separated list of QNames that identify xsl:attribute-set declarations. This attribute is used only when copying element nodes. This list is expanded as described in 10.2 Named Attribute Sets to produce a sequence of attribute nodes. This sequence is prepended to the sequence produced as a result of evaluating the sequence constructor.
The xsl:copy instruction has an optional copy-namespaces attribute, with the value yes or no. The default value is yes. The attribute is used only when copying element nodes. If the value is set to yes, or is omitted, then all the namespace nodes of the source element are copied as namespace nodes for the result element. These copied namespace nodes are prepended to the sequence produced as a result of evaluating the sequence constructor (it is immaterial whether they come before or after any attribute nodes produced by expanding the use-attribute-sets attribute). If the value is set to no, then the namespace nodes are not copied. However, namespace nodes will still be added to the result element as required by the namespace fixup process: see 5.8.3 Namespace Fixup.
The xsl:copy instruction has an optional inherit-namespaces attribute, with the value yes or no. The default value is yes. The attribute is used only when copying element nodes. If the value is set to yes, or is omitted, then the namespace nodes created for the newly constructed element (whether these were copied from those of the source node, or generated as a result of namespace fixup) are copied to the children and descendants of the newly constructed element, as described in 5.8.1 Constructing Complex Content. If the value is set to no, then these namespace nodes are not automatically copied to the children. This may result in namespace undeclarations (such as xmlns="" or, in the case of XML Namespaces 1.1, xmlns:p="") appearing on the child elements when a final result tree is serialized.
[ERR XTTE0950] It is a type error to use the xsl:copy or xsl:copy-of instruction to copy a node that has namespace-sensitive content if the copy-namespaces attribute has the value no and its explicit or implicit validation attribute has the value preserve. It is also a type error if either of these instructions (with validation="preserve") is used to copy an attribute having namespace-sensitive content, unless the parent element is also copied. A node has namespace-sensitive content if its typed value contains an item of type xs:QName or xs:NOTATION or a type derived therefrom. The reason this is an error is because the validity of the content depends on the namespace context being preserved.
Note:
When attribute nodes are copied, whether with xsl:copy or with xsl:copy-of, the processor does not automatically copy any associated namespace information. The namespace used in the attribute name itself will be declared by virtue of the namespace fixup process (see 5.8.3 Namespace Fixup) when the attribute is added to an element in the result tree, but if namespace prefixes are used in the content of the attribute (for example, if the value of the attribute is an XPath expression) then it is the responsibility of the stylesheet author to ensure that suitable namespace nodes are added to the result tree. This can be achieved by copying the namespace nodes using xsl:copy, or by generating them using xsl:namespace.
The optional attributes type and validation may be used on the xsl:copy instruction to validate the contents of an element, attribute or document node against a type definition, element declaration, or attribute declaration in a schema, and thus to determine the type annotation that the new copy of an element or attribute node will carry. These attributes are ignored when copying an item that is not an element, attribute or document node. When the node being copied is an element or document node, these attributes also affect the type annotation carried by any elements and attributes that have the copied element or document node as an ancestor. These two attributes are both optional, and if one is specified then the other must be omitted. The permitted values of these attributes and their semantics are described in 26.425.4 Validation.
Note:
The final type annotation of the node in the result tree also depends on the type and validation attributes of the instructions used to create the ancestors of the node.
When a node is copied, its base URI is copied, except when the result of the xsl:copy instruction is an element node having an xml:base attribute, in which case the base URI of the new node is taken as the value of its xml:base attribute, resolved if it is relative against the base URI of the xsl:copy instruction.
When an xml:id attribute is copied, using either the xsl:copy or xsl:copy-of instruction, it is implementation-defined whether the value of the attribute is subjected to attribute value normalization (that is, effectively applying the normalize-space function).
Note:
In most cases the value will already have been subjected to attribute value normalization on the source tree, but if this processing has not been performed on the source tree, it is not an error for it to be performed on the result tree.
<!-- Category: instruction -->
<xsl:copy-of
select = expression
copy-accumulators? = boolean〔'no'〕
copy-namespaces? = boolean〔'yes'〕
type? = eqname
validation? = "strict" | "lax" | "preserve" | "strip" />
The xsl:copy-of instruction can be used to construct a copy of a sequence of nodes, atomic items, and/or function items with each new node containing copies of all the children, attributes, and (by default) namespaces of the original node, recursively. The result of evaluating the instruction is a sequence of items corresponding one-to-one with the supplied sequence, and retaining its order.
The requiredselect attribute contains an expression, whose value may be any sequence of nodes, atomic items, and/or function items. The items in this sequence are processed as follows:
If the item is an element node, a new element is constructed and appended to the result sequence. The new element will have the same expanded QName as the original, and it will have deep copies of the attribute nodes and children of the element node.
The new element will also have namespace nodes copied from the original element node, unless they are excluded by specifying copy-namespaces="no". If this attribute is omitted, or takes the value yes, then all the namespace nodes of the original element are copied to the new element. If it takes the value no, then none of the namespace nodes are copied: however, namespace nodes will still be created in the result tree as required by the namespace fixup process: see 5.8.3 Namespace Fixup. This attribute affects all elements copied by this instruction: both elements selected directly by the selectexpression, and elements that are descendants of nodes selected by the select expression.
The values of the is-id, is-idrefs, and nilled properties of the new element depend on the values of the validation and type attributes, as defined in 26.425.4 Validation.
If the item is a document node, the instruction adds a new document node to the result sequence; the children of this document node will be one-to-one copies of the children of the original document node (each copied according to the rules for its own node kind). The unparsed-entities property of the original document node is copied to the new document node.
If the item is an attribute or namespace node, or a text node, a comment, or a processing instruction, the same rules apply as with xsl:copy (see 11.9.1 Shallow Copy).
If the item is an atomic item or a function item, the value is appended to the result sequence, as with xsl:sequence.
The optional attributes type and validation may be used on the xsl:copy-of instruction to validate the contents of an element, attribute or document node against a type definition, element declaration, or attribute declaration in a schema and thus to determine the type annotation that the new copy of an element or attribute node will carry. These attributes are applied individually to each element, attribute, and document node that is selected by the expression in the select attribute. These attributes are ignored when copying an item that is not an element, attribute or document node.
The specified type and validation apply directly only to elements, attributes and document nodes created as copies of nodes actually selected by the select expression, they do not apply to nodes that are implicitly copied because they have selected nodes as an ancestor. However, these attributes do indirectly affect the type annotation carried by such implicitly copied nodes, as a consequence of the validation process.
These two attributes are both optional, and if one is specified then the other must be omitted. The permitted values of these attributes and their semantics are described in 26.425.4 Validation.
Errors may occur when copying namespace-sensitive elements or attributes using validation="preserve". [see ERR XTTE0950].
If removal of namespaces is requested using copy-namespaces="no", then any validation that is requested is applied to the tree that remains after the relevant namespaces have been removed. This will cause validation to fail if there is namespace-sensitive content that depends on the presence of the removed namespaces.
For any node N that is explicitly selected by the evaluation of the select expression, the base URI of the new copy is as follows:
If N is an element node having an xml:base attribute, the base URI of the new node is taken as the value of the xml:base attribute, resolved if it is relative against the static base URI of the xsl:copy-of instruction.
Otherwise, the base URI of the new copy is the same as the base URI of N.
For any element or processing-instruction node that has N as an ancestor, the base URI of the new copy is set to be the same as that of its new parent, with the following exception: if a copied element has an xml:base attribute, then its base URI is set to the value of that attribute, resolved if it is relative against the base URI of the new parent node.
Note:
If two elements in a subtree have different base URIs for some reason unconnected with xml:base attributes (for example, if they originated in different external entities), then these differences are lost when the subtree is copied.
Note:
As a consequence of rules specified elsewhere (see 5.8.1 Constructing Complex Content), if a node created using the xsl:copy-of instruction is subsequently attached as a child to a new element or document node, the final copy of the node inherits its base URI from its new parent node, unless this is overridden using an xml:base attribute.
[XSLT 3.0 Erratum E16, bug 30222]
The effect of the copy-accumulators attribute is described in 18.2.2 Applicability of Accumulators.
The xsl:merge instruction allows a sorted sequence of items to be constructed by merging several input sequences. Each input sequence must have a merge key (one or more atomic items that can be computed as a function of the items in the sequence); the input sequence must either already be sorted on the value of its merge keys, or pre-sorting on these values must be requested. The merge keys for the different input sequences must be compatible in the sense that key values from an item in one sequence are always comparable with key values from an item in a different sequence.
For example, if two log files contain details of events sorted by date and time, then the xsl:merge instruction can be used to combine these into a single sequence that is also sorted by date and time.
The data written to the output sequence can be computed in an arbitrary way from the data in the input sequences, provided it follows the ordering of the input sequences.
The xsl:merge instruction can be used to merge several sequences of items that all have the same structure (more precisely, sequences whose merge keys are computed in the same way): for example, log files created by the same application running on different machines in a server farm. Alternatively, xsl:merge can be used to merge sequences that have different structure (sequences whose merge keys are computed in different ways), provided that the computed merge keys are compatible: an example might be two log files created by different applications, using different XML vocabularies, that both contain timestamped events but represent the timestamp in different ways. The xsl:merge-source element represents a set of input sequences that follow common rules, including the rules for computing the merge key. The xsl:merge operation may take any number of xsl:merge-source elements representing different rules for input sequences, and each xsl:merge-source element may describe any number (zero or more) of input sequences. The number of input sequences to the merging operation is thus fixed only at the time the xsl:merge instruction is evaluated, and may vary from one evaluation to another.
The following examples illustrate some of the possibilities. The detailed explanation of the constructs used follows later in this section.
This example takes as input a homogeneous collection of XML log files each of which contains a sorted sequence of event elements with a timestamp attribute validated as an instance of xs:dateTime. It merges the events from the input files into a single sorted output file.
<xsl:result-document href="merged-events.xml"> <events> <xsl:merge> <xsl:merge-source for-each-source="uri-collection('log-files')" select="events/event"> <xsl:merge-key select="@timestamp"/> </xsl:merge-source> <xsl:merge-action> <xsl:copy-of select="current-merge-group()"/> </xsl:merge-action> </xsl:merge> </events> </xsl:result-document>
The example assumes that there are several input files each of which has a structure similar to the following, in which the timestamp attribute has a typed value that is an instance of xs:dateTime:
<events> <event timestamp="2009-08-20T12:01:01Z">Transaction T1234 started</event> <event timestamp="2009-08-20T12:01:08Z">Transaction T1235 started</event> <event timestamp="2009-08-20T12:01:12Z">Transaction T1235 ended</event> <event timestamp="2009-08-20T12:01:15Z">Transaction T1234 ended</event> </events>
The output file will have the same structure, and will contain copies of all the event elements from all of the input files, in sorted order. Note that multiple events with the same timestamp can occur either within a single file or across multiple files: the order of appearance of these events in the output file corresponds to the order of the log files within the collection (which might or might not be predictable, depending on the implementation).
This example takes as input two log files with different structure, producing a single merged output in which the entries have a common structure:
<xsl:result-document href="merged-events.xml"> <events> <xsl:merge> <xsl:merge-source select="doc('log-file-1.xml')/events/event"> <xsl:merge-key select="@timestamp"/> </xsl:merge-source> <xsl:merge-source select="doc('log-files-2.xml')/log/day/record"> <xsl:merge-key select="dateTime(../@date, time)"/> </xsl:merge-source> <xsl:merge-action> <xsl:apply-templates select="current-merge-group()" mode="standardize-log-entry"/> </xsl:merge-action> </xsl:merge> </events> </xsl:result-document>
Here the first input file has a structure similar to that shown in the previous example, while the second input has a different structure, of the form:
<log> <day date="2009-08-20"> <record> <time>12:01:09-05:00</time> <message>Temperature 15.4C</message> </record> <record> <time>12:03:00-05:00</time> <message>Temperature 18.2C</message> </record> </day> </log>
The templates in mode standardize-log-entry convert the log entries to a common output format, for example:
<xsl:template match="event" mode="standardize-log-entry" as="schema-element(event)"> <xsl:copy-of select="." validation="preserve"/> </xsl:template> <xsl:template match="record" mode="standardize-log-entry" as="schema-element(event)"> <event timestamp="{dateTime(../@date, time)}" xsl:validation="strict"> <xsl:value-of select="message"/> </event> </xsl:template>
Note:
The xsl:merge instruction is designed to enable streaming of data, so that there is no need to allocate memory to hold the input sequences. However, it can also be used in cases where streamed processing is not possible, for example when the input needs to be sorted.
<xsl:merge-source
name? = ncname
for-each-item? = expression
for-each-source? = expression
select = expression
streamable? = boolean
use-accumulators? = tokens〔''〕
sort-before-merge? = boolean〔'no'〕
validation? = "strict" | "lax" | "preserve" | "strip"
type? = eqname >
<!-- Content: xsl:merge-key+ -->
</xsl:merge-source>
Each xsl:merge-source element defines one or more merge input sequences.
The name attribute provides a means of distinguishing items from different merge sources within the xsl:merge-action instructions. If the name attribute is present on an xsl:merge-source element, then it must not be equal to the name attribute of any sibling xsl:merge-source element. If the name attribute is absent, then an implementation-dependent name, different from all explicitly specified names, is allocated to the merge source.
[ERR XTSE3195] If the for-each-item attribute is present then the for-each-source, use-accumulators, and streamable attributes must all be absent. If either or both of the use-accumulators or streamable attributes is present then the for-each-source attribute must be present. If the for-each-source attribute is present then the for-each-item attribute must be absent. [XSLT 3.0 Erratum E40, bugs 30265 and 30378].
The use-accumulators attribute defines the set of accumulators that are applicable to the streamed document, as explained in 18.2.2 Applicability of Accumulators.
If neither of for-each-item and for-each-source is present, the xsl:merge-source element defines a single merge input sequence. This sequence is the result of evaluating the expression in the select attribute. This is evaluated using the dynamic context of the containing xsl:merge instruction. This sequence will be merged with the sequences defined by other xsl:merge-source elements, if present.
When the for-each-item attribute is present, the xsl:merge-source element defines a collection of merge input sequences. The selection of items in these input sequences is a two-stage process: the for-each-item attribute of the xsl:merge-source element is an expression that selects a sequence of anchor items, and for each anchor item, the select attribute is evaluated to select the items that make up one merge input sequence. The for-each-item expression is evaluated with the dynamic context of the containing xsl:merge instruction, while the select attribute is evaluated with the focus for the evaluation as follows:
The context item is the anchor item
The context position is the position of the anchor item within the sequence of anchor items
The context size is the number of anchor items.
When the for-each-source attribute is present, its value must be an expression that returns a sequence of URIs. The expression is evaluated with the same dynamic context as the containing xsl:merge instruction. The expected type of the expression is xs:string*, and the actual result of the expression is converted to this type using the coercion rules. Each of these URIs is used to obtain a document node. Each must be a valid URI reference. If it is an absolute URI reference, it is used as is; if it is a relative URI reference, it is made absolute by resolving it against the base URI of the xsl:merge-source element. The process of obtaining a document node given a URI is the same as for the doc function, and may trigger the same error conditions. However, unlike the doc function, the xsl:merge instruction offers no guarantee that the resulting document will be stable (that is, that multiple calls specifying the same URI will return the same document). The resulting document nodes act as the anchor items. These anchor items are then used in the same way as a sequence of anchor items selected directly using the for-each-item attribute: in particular, the focus is determined in the same way.
Note:
Examples of expressions that return a sequence of URIs are:
for-each-source="'inputA.xml', 'inputB.xml'"
for-each-source="(1 to $N) ! ('input' || $N || '.xml')"
for-each-source="uri-collection('input/dir/')
Relative URIs are resolved relative to the base URI of the xsl:merge-source element.
The attributes validation and type are used to control schema validation of documents read by virtue of their appearance in the result of the for-each-source expression. These attributes are mutually exclusive [see ERR XTSE1505]. If the for-each-source attribute is absent, then the validation and type attributes must both be absent. The process of validation follows the rules defined in 26.425.4 Validation [XSLT 3.0 Erratum E44, bug 30384].
If the sort-before-merge attribute is absent or has the value no, then each merge input sequence must already be in the correct order for merging (a dynamic error occurs if it is not). If the attribute is present with the value yes, then each input sequence will first be sorted to ensure that it is in the correct order. The sorting is carried out as if by evaluating an xsl:perform-sort instruction with xsl:sort children corresponding one-to-one with the xsl:merge-key children of the xsl:merge-source element, differing only (a) in the change of element name, and (b) in the addition of the attribute stable="yes" to the first such element. [XSLT 3.0 Erratum E41, bug 30380].
The following xsl:merge-source element selects two anchor items (the root nodes of two documents), and for each of these it selects an input sequence consisting of selected event elements within the relevant document.
<xsl:merge-source for-each-source="'log-A.xml', 'log-B.xml'" streamable="yes" select="events/event"> <xsl:merge-key select="@timestamp" order="ascending"/> </xsl:merge-source>
This example can be extended to merge any number of input documents with the same structure:
<xsl:merge-source for-each-source="uri-collection('log-collection')" streamable="yes" select="events/event"> <xsl:merge-key select="@time" order="ascending"/> </xsl:merge-source>
In both the above examples the anchor items are document nodes, and the items in the input sequence are elements within the document that is rooted at this node. This is a common usage pattern, but by no means the only way in which the construct can be used.
The number of anchor items selected by an xsl:merge-source element, and therefore the number of input sequences, is variable, but the input sequences selected by one xsl:merge-source element must all use the same expressions to select the items in the input sequence and to compute their merge keys. If different expressions are needed for different input sequences, then multiple xsl:merge-source elements can be used.
The following code merges two log files having different internal structure:
<xsl:merge-source for-each-source="'event-log.xml'" streamable="yes" select="/*/event"> <xsl:merge-key select="@timestamp"/> </xsl:merge-source> <xsl:merge-source for-each-source="'error-log.xml'" streamable="yes" select="/*/error"> <xsl:merge-key select="dateTime(@date, @time)"/> </xsl:merge-source>
Although the merge keys are computed in different ways for the two input sequences, the keys must be compatible across the two sequences: in this case they are both atomic items of type xs:dateTime.
In the common case where there is only one input sequence of a particular kind, the for-each-item attribute of xsl:merge-source may be omitted; the select expression is then evaluated relative to the focus of the xsl:merge instruction itself.
Where one or more of the inputs to the merging process is not pre-sorted, a sort can be requested using the sort-before-merge attribute. For example:
<xsl:merge-source select="doc('event-log.xml')/*/event"> <xsl:merge-key select="@timestamp"/> </xsl:merge-source> <xsl:merge-source select="doc('error-log.xml')//error" sort-before-merge="yes"> <xsl:merge-key select="dateTime(current-date(), @time)"/> </xsl:merge-source>
[ERR XTSE3190] It is a static error if two sibling xsl:merge-source elements have the same name.
XSLT 3.0 introduces a number of constructs that are specifically designed to enable streamed applications to be written, but which are also useful in their own right; it also includes some features that are very specialized to streaming.
xsl:source-document Instruction<!-- Category: instruction -->
<xsl:source-document
href = { uri }
streamable? = boolean〔'no'〕
use-accumulators? = tokens〔''〕
validation? = "strict" | "lax" | "preserve" | "strip"
type? = eqname >
<!-- Content: sequence-constructor -->
</xsl:source-document>
The xsl:source-document instruction reads a source document whose URI is supplied, and processes the content of the document by evaluating the contained sequence constructor. The streamable attribute (default "no") allows streamed processing to be requested.
For example, if a document represents a book holding a sequence of chapters, then the following code can be used to split the book into multiple XML files, one per chapter, without allocating memory to hold the entire book in memory at one time:
<xsl:source-document streamable="yes" href="book.xml"> <xsl:for-each select="book"> <xsl:for-each select="chapter"> <xsl:result-document href="chapter{position()}.xml"> <xsl:copy-of select="."/> </xsl:result-document> </xsl:for-each> </xsl:for-each> </xsl:source-document>
Note:
In earlier drafts of this specification the xsl:source-document element was named xsl:stream. The instruction has been generalised to handle both streamed and unstreamed input.
The document to be read is determined by the effective value of the href attribute (which is defined as an attribute value template). This must be a valid URI reference. If it is an absolute URI reference, it is used as is; if it is a relative URI reference, it is made absolute by resolving it against the base URI of the xsl:source-document element. The process of obtaining a document node given a URI is the same as for the doc function. However, unlike the doc function, the xsl:source-document instruction offers no guarantee that the resulting document will be stable (that is, that multiple calls specifying the same URI will return the same document).
Specifically, if an xsl:source-document instruction is evaluated several times (or if different xsl:source-document instructions are evaluated) with the same URI (after making it absolute) as the value of the href attribute, it is implementation-dependent whether the same nodes or different nodes are returned on each occasion; it is also possible that the actual document content will be different.
Note:
A different node will necessarily be returned if there are differences in attributes such as validation, type, streamable, or use-accumulators, or if the calls are in different packages with variations in the rules for whitespace stripping or stripping of type annotations.
The result of the xsl:source-document instruction is the same as the result of the following (non-streaming) process:
The source document is read from the supplied URI and parsed to form a tree of nodes in the XDM data model.
The contained sequence constructor is evaluated with the root node of this tree as the context item, and with the context position and context size set to one; and the resulting sequence is returned as the result of the xsl:source-document instruction.
The xsl:source-document instruction is guaranteed-streamable if both the following conditions are satisfied:
It is declared-streamable, by specifying streamable="yes".
the contained sequence constructor is grounded, as assessed using the streamability analysis in 19 Streamability. The consequences of being or not being guaranteed streamable depend on the processor conformance level, and are explained in 19.10 Streamability Guarantees.
The use-accumulators attribute defines the set of accumulators that are applicable to the document, as explained in 18.2.2 Applicability of Accumulators.
Note:
The following notes apply specifically to streamed processing.
The rules for guaranteed streamability ensure that the sequence constructor (and therefore the xsl:source-document instruction) cannot return any nodes from the streamed document. For example, it cannot contain the instruction <xsl:sequence select="//chapter"/>. If nodes from this document are to be returned, they must first be copied, for example by using the xsl:copy-of instruction or by calling the copy-of or snapshot functions.
Because the xsl:source-document instruction cannot (if it satisfies the rules for guaranteed streamability) return nodes from the streamed document, any nodes it does return will be conventional (unstreamed) nodes that can be processed without restriction. For example, if xsl:source-document is invoked within a stylesheet functionf:firstChapter, and the sequence constructor consists of the instruction <xsl:copy-of select="//chapter"/>, then the calling code can manipulate the resulting chapter elements as ordinary trees rooted at parentless element nodes.
If the sequence constructor in an xsl:source-document instruction were to return nodes from the document for which streaming has been requested, the instruction would not be guaranteed streamable. Processors which support the streaming feature would then not be required to process it in a streaming manner, and this specification imposes no restrictions on the processing of the nodes returned. (The ability of a streaming processor to handle such stylesheets in a streaming manner might, of course, depend on how the nodes returned are processed, but those details are out of scope for this specification.)
The validation and type attributes of xsl:source-document may be used to control schema validation of the input document. They have the same effect as the corresponding attributes of the xsl:copy-of instruction when applied to a document node, except that when streamable="yes" is specified, the copy that is produced is itself a streamed document. The process is described in more detail in 26.4.225.4.2 Validating Document Nodes.
These two attributes are both optional, and if one is specified then the other must be omitted ([see ERR XTSE1505]).
The presence of a validation or type attribute on an xsl:source-document instruction causes any input-type-annotations attribute to have no effect on any document read using that instruction.
Note:
In effect, setting validation to strict or lax, or supplying the type attribute, requests document-level validation of the input as it is read. Setting validation="preserve" indicates that if the incoming document contains type annotations (for example, produced by validating the output of a previous step in a streaming pipeline) then they should be retained, while the value strip indicates that any such type annotations should be dropped.
It is a consequence of the way validation is defined in XSD that the type annotation of an element node can be determined during the processing of its start tag, although the actual validity of the element is not known until the end tag is encountered. When validation is requested, a streamed document should not present data to the stylesheet except to the extent that such data could form the leading part of a valid document. If the document proves to be invalid, the processor should not pass invalid data to the stylesheet to be processed, but should immediately raise the appropriate error. For the purposes of xsl:try and xsl:catch, this error can only be caught at the level of the xsl:source-document instruction that initiated validation, not at a finer level. If validation errors are caught in this way, any output that has been computed up to the point of the error is not added to the final result tree; the mechanisms to achieve this may use memory, which may reduce the efficacy of streaming.
The analysis of guaranteed streamability (see 19 Streamability) takes no account of information that might be obtained from a schema-aware static analysis of the stylesheet. Implementations may, however, be able to use streaming strategies for stylesheets that are not guaranteed-streamable, by taking advantage of such information. For example, an implementation might be able to treat the expression .//title as striding rather than crawling if it can establish from knowledge of the schema that two title elements will never be nested one inside the other.
Functions that accept a lexical QName as an argument, such as key, function-available, element-available, type-available, system-property, accumulator-before, and accumulator-after, now have the option of supplying an xs:QName value instead. [This change was in the editor's draft accepted by the WG as its baseline when it started work.] [ 1 January 2022]
This section describes XSLT-specific additions to the XPath function library. Some of these additional functions also make use of information specified by declarations in the stylesheet; this section also describes these declarations.
Returns the value of a system property
fn:system-property( | ||
$name | as (xs:string | xs:QName) | |
) as xs:string | ||
This function is deterministicFO, focus-independentFO, and context-dependentFO. It depends on namespaces.
The value of the $name argument must be either an xs:QName, or a string containing an EQName. If it is a lexical QName with a prefix, then it is expanded into an expanded QName using the namespace declarations in the static context of the expression. If there is no prefix, the name is taken as being in no namespace.
The system-property function returns a string representing the value of the system property identified by the name. If there is no such system property, the zero-length string is returned.
Implementations must provide the following system properties, which are all in the XSLT namespace:
xsl:version, a number giving the version of XSLT implemented by the processor; for implementations conforming to the version of XSLT specified by this document, this is the string "4.0". The value will always be a string in the lexical space of the decimal datatype defined in XML Schema (see [XML Schema Part 2]). This allows the value to be converted to a number for the purpose of magnitude comparisons.
xsl:vendor, a string identifying the implementer of the processor
xsl:vendor-url, a string containing a URL identifying the implementer of the processor; typically this is the host page (home page) of the implementer’s Web site.
xsl:product-name, a string containing the name of the implementation, as defined by the implementer. This should normally remain constant from one release of the product to the next. It should also be constant across platforms in cases where the same source code is used to produce compatible products for multiple execution platforms.
xsl:product-version, a string identifying the version of the implementation, as defined by the implementer. This should normally vary from one release of the product to the next, and at the discretion of the implementer it may also vary across different execution platforms.
xsl:is-schema-aware, returns the string "yes" in the case of a processor that claims conformance as a schema-aware XSLT processor, or "no" in the case of a basic XSLT processor.
xsl:supports-serialization, returns the string "yes" in the case of a processor that offers the serialization feature, or "no" otherwise.
xsl:supports-backwards-compatibility, returns the string "yes" in the case of a processor that offers the XSLT 1.0 compatibility feature, or "no" otherwise.
xsl:supports-namespace-axis, returns the string "yes" in the case of a processor that offers the XPath namespace axis even when not in backwards compatible mode, or "no" otherwise. Note that a processor that supports backwards compatible mode must support the namespace axis when in that mode, so this property is not relevant to that case.
xsl:supports-streaming, returns the string "yes" in the case of a processor that offers the streaming feature (see 28.527.5 Streaming Feature), or "no" otherwise.
xsl:supports-dynamic-evaluation, returns the string "yes" in the case of a processor that offers the dynamic evaluation feature (see 28.627.6 Dynamic Evaluation Feature), or "no" otherwise.
xsl:supports-higher-order-functions, always returns the string "yes".
Note:
In XSLT 4.0, support for higher-order functions is no longer an optional feature.xsl:xpath-version, a number giving the version of XPath implemented by the processor; for implementations conforming to the version of XSLT specified by this document, this is the string "4.0". The value will always be a string in the lexical space of the decimal datatype defined in XML Schema (see [XML Schema Part 2]). This allows the value to be converted to a number for the purpose of magnitude comparisons.
xsl:xsd-version, a number giving the version of XSD (XML Schema) implemented by the processor. The value will always be a string in the lexical space of the decimal datatype defined in XML Schema (see [XML Schema Part 2]). This allows the value to be converted to a number for the purpose of magnitude comparisons. Typical values are "1.0" or "1.1". This property is relevant even when the processor is not schema-aware, since the built-in datatypes for XSD 1.1 differ from those in XSD 1.0.
Some of these properties relate to the conformance levels and features offered by the processor: these options are described in 2827 Conformance.
Except where otherwise specified, the actual values returned for the above properties are implementation-defined.
The set of system properties that are supported, in addition to those listed above, is also implementation-defined. Implementations must not define additional system properties in the XSLT namespace.
[ERR XTDE1390] It is a dynamic error if the value supplied as the $property-name argument is not a valid QName, or if there is no namespace declaration in scope for the prefix of the QName. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
An implementation must not return the value 3.0 as the value of the xsl:version system property unless it is conformant to XSLT 3.0.
It is recognized that vendors who are enhancing XSLT 1.0 or 2.0 processors may wish to release interim implementations before all the mandatory features of this specification are implemented. Since such products are not conformant to XSLT 3.0, this specification cannot define their behavior. However, implementers of such products are encouraged to return a value for the xsl:version system property that is intermediate between 1.0 and 3.0, and to provide the element-available and function-available functions to allow users to test which features have been fully implemented.
TODO: add change metadata (PR 1243)
JSON is a popular format for exchange of structured data on the web: it is specified in [RFC 7159]. This section describes facilities allowing JSON data to be processed using XSLT.
Note:
RFC7159 is taken as the definitive specification of JSON for the purposes of this document. The RFC explains its relationship with other JSON specifications such as [ECMA-404].
Note:
XPath 3.1 incorporates the functions defined in this section. It also provides additional JSON capability, in the form of functions parse-json, json-doc, and extensions to the serialize function. These facilities are incorporated in XSLT 3.0 only if the XPath 3.1 feature is supported. They depend on support for arrays.
Given an XML structure that does not use the XML representation of JSON defined in Section 14.3.2 XML Representation of JSONFO, there are two practical ways to convert it to JSON: either perform a transformation to the XML representation of JSON and then call the xml-to-json function; or transform it to JSON directly by using custom template rules.
To assist with the second approach, a stylesheet is provided in B XML Representation of JSON. This stylesheet includes a function j:xml-to-json which, apart from being in a different namespace, is functionally very similar to the xml-to-json function described in the previous section. (It differs in doing less validation of the input than the function specification requires, and in the details of how special characters are escaped.) The implementation of the function is exposed, using template rules to perform a recursive descent of the supplied input, and the behavior of the function can therefore be customized (typically by importing the stylesheet and adding additional template rules) to handle arbitrary XML input.
The stylesheet is provided under the W3C software license for the convenience of users. There is no requirement for any conformant XSLT processor to make this stylesheet available. Processors may implement the xml-to-json function by invoking this stylesheet (adapted to achieve full conformance), but there is no requirement to do so.
<!-- Category: instruction -->
<xsl:message
select? = expression
terminate? = { boolean }〔'no'〕
error-code? = { eqname }〔'Q{http://www.w3.org/2005/xqt-errors}XTMM9000'〕 >
<!-- Content: sequence-constructor -->
</xsl:message>
The xsl:message instruction sends a message in an implementation-defined way. The xsl:message instruction causes the creation of a new document, which is typically serialized and output to an implementation-defined destination. The result of the xsl:message instruction is an empty sequence.
The content of the message may be specified by using either or both of the optional select attribute and the sequence constructor that forms the content of the xsl:message instruction.
If the xsl:message instruction contains a sequence constructor, then the sequence obtained by evaluating this sequence constructor is used to construct the content of the new document node, as described in 5.8.1 Constructing Complex Content.
If the xsl:message instruction has a select attribute, then the value of the attribute must be an XPath expression. The effect of the xsl:message instruction is then the same as if a single xsl:copy-of instruction with this select attribute were added to the start of the sequence constructor.
If the xsl:message instruction has no content and no select attribute, then an empty message is produced.
The tree produced by the xsl:message instruction is not technically a final result tree. The tree has no URI and processors are not required to make the tree accessible to applications.
Note:
In many cases, the XML document produced using xsl:message will consist of a document node owning a single text node. However, it may contain a more complex structure.
Note:
An implementation might implement xsl:message by popping up an alert box or by writing to a log file. Because the order of execution of instructions is implementation-defined, the order in which such messages appear is not predictable.
The terminate attribute is interpreted as an attribute value template.
If the effective value of the terminate attribute is yes, then the processormust raise a dynamic error after sending the message. This error may be caught in the same way as any other dynamic error using xsl:catch. The default value is no. Note that because the order of evaluation of instructions is implementation-dependent, this gives no guarantee that any particular instruction will or will not be evaluated before processing terminates.
The optional error-code attribute (also interpreted as an attribute value template) may be used to indicate the error code associated with the message. This may be used irrespective of the value of terminate. The effective value of the error code attribute is expected to be an EQName. If no error code is specified, or if the effective value is not a valid EQName, the error code will have local part XTMM9000 and namespace URI http://www.w3.org/2005/xqt-errors. User-defined error codes should be in a namespace other than http://www.w3.org/2005/xqt-errors. When the value of terminate is yes, the error code may be matched in an xsl:catch element to catch the error and cause processing to continue normally.
[ERR XTMM9000] When a transformation is terminated by use of <xsl:message terminate="yes"/>, the effect is the same as when a dynamic error occurs during the transformation. The default error code is XTMM9000; this may be overridden using the error-code attribute of the xsl:message instruction.
One convenient way to do localization is to put the localized information (message text, etc.) in an XML document, which becomes an additional input file to the stylesheet. For example, suppose messages for a language L are stored in an XML file resources/L.xml in the form:
<messages> <message name="problem">A problem was detected.</message> <message name="error">An error was detected.</message> </messages>
Then a stylesheet could use the following approach to localize messages:
<xsl:param name="lang" select="'en'"/> <xsl:variable name="messages" select="document(concat('resources/', $lang, '.xml'))/messages"/> <xsl:template name="localized-message"> <xsl:param name="name"/> <xsl:message select="string($messages/message[@name=$name])"/> </xsl:template> <xsl:template name="problem"> <xsl:call-template name="localized-message"> <xsl:with-param name="name">problem</xsl:with-param> </xsl:call-template> </xsl:template>
Any dynamic error that occurs while evaluating the select expression or the contained sequence constructor, and any serialization error that occurs while processing the result, does not cause the transformation to fail; at worst, it means that no message is output, or that the only message that is output is one that relates to the error that occurred.
Note:
An example of such an error is the serialization error that occurs when processing the instruction <xsl:message select="@code"/> (on the grounds that free-standing attributes cannot be serialized). Making such errors recoverable means that it is implementation-defined whether or not they are raised to the user and whether they cause termination of the transformation. If the processor chooses to recover from the error, the content of any resulting message is implementation-dependent.
One possible recovery action is to include a description of the error in the generated message text.
The xsl:assert instruction is used to assert that the value of a particular expression is true; if the value of the expression is false, and assertions are enabled, then a dynamic error occurs.
<!-- Category: instruction -->
<xsl:assert
test = expression
select? = expression
error-code? = { eqname }〔'Q{http://www.w3.org/2005/xqt-errors}XTMM9001'〕 >
<!-- Content: sequence-constructor -->
</xsl:assert>
By default, assertions are disabled.
An implementation must provide an external mechanism to enable or disable assertion checking. This may work either statically or dynamically, and may be at the level of the stylesheet as a whole, or at the level of an individual package, or otherwise. The detail of such mechanisms is implementation-defined.
If assertion checking is enabled, the instruction is evaluated as follows:
The expression in the test attribute is evaluated. If the effective boolean value of the result is true, the assertion succeeds, and no further action is taken. If the effective boolean value is false, or if a dynamic error occurs during evaluation of the expression, then the assertion fails.
If the assertion fails, then the effect of the instruction is governed by the rules for evaluation of an xsl:message instruction with the same select attribute, error-code attribute, and contained sequence constructor, and with the value terminate="yes". However, the default error code if the error-code attribute is omitted is XTMM9001 rather than XTMM9000.
Note:
To the extent that the behavior of xsl:message is implementation-defined, this rule does not prevent an implementation treating xsl:assert and xsl:message differently.
Note:
If evaluation of the test expression fails with a dynamic error, the effect is exactly the same as if the evaluation returns false, including the fact that the instruction fails with error code XTMM9001.
If an assertion fails, then the following sibling instructions of the xsl:assert instruction are not evaluated.
Note:
This means that xsl:assert can be used (rather like xsl:if and xsl:choose) to prevent subsequent instructions from executing if a particular precondition is not true, which might be useful if the subsequent instructions have side-effects (for example, by calling extension functions) or if they can fail in uncatchable ways (for example, non-terminating recursion). It is worth noting that there are limits to this guarantee. It does not ensure, for example, that when an assertion within a template fails, the following siblings of the xsl:call-template instruction that invokes that template will not be evaluated; nor does it ensure that if an assertion fails while processing the first item of a sequence using xsl:for-each, then subsequent items in the sequence will not be processed.
[ERR XTMM9001] When a transformation is terminated by use of xsl:assert, the effect is the same as when a dynamic error occurs during the transformation. The default error code is XTMM9001; this may be overridden using the error-code attribute of the xsl:assert instruction.
As with any other dynamic error, an error caused by an assertion failing may be trapped using xsl:try: see 8.4 Try/Catch.
The result of the xsl:assert instruction is an empty sequence.
The following example shows a stylesheet function that checks that the value of its supplied argument is in range. The check is performed only if the static parameter$DEBUG is set to true.
<xsl:param name="DEBUG" as="xs:boolean" select="false()" static="yes" required="no"/> <xsl:function name="f:days-elapsed" as="xs:integer"> <xsl:param name="date" as="xs:date"/> <xsl:assert use-when="$DEBUG" test="$date lt current-date()"/> <xsl:sequence select="(current-date() - $since) div xs:dayTimeDuration('PT1D')"/> </xsl:function>
Note:
Implementations should avoid optimizing xsl:assert instructions away. As a guideline, if the result of a sequence constructor is required by the transformation, the implementation should ensure that all xsl:assert instructions in that sequence constructor are evaluated. Conversely, if the result of a sequence constructor is not required by the transformation, its xsl:assert instructions should not be evaluated.
This guidance is not intended to prevent optimizations such as lazy evaluation, where evaluation of a sequence constructor may finish early, as soon as enough information is available to evaluate the containing instruction.
An implementation may provide a user option allowing a processor to treat assertions as being true without explicit checking. This option must not be enabled by default. If such an option is in force, the effect of any assertion not being true is implementation-dependent.
Note:
For example, given the assertion <xsl:assert test="count(//title)=1"/>, a processor might generate code for the expression <xsl:value-of select="//title"/> that stops searching for title elements after finding the first one. In the event that the source document contains more than one title, execution of the stylesheet may fail in arbitrary ways, or it may produce incorrect output.
Functions that accept a lexical QName as an argument, such as key, function-available, element-available, type-available, system-property, accumulator-before, and accumulator-after, now have the option of supplying an xs:QName value instead. [This change was in the editor's draft accepted by the WG as its baseline when it started work.] [ 1 January 2022]
XSLT allows two kinds of extension, extension instructions and extension functions.
[Definition: An extension instruction is an element within a sequence constructor that is in a namespace (not the XSLT namespace) designated as an extension namespace.]
[Definition: An extension function is a named function introduced to the static or dynamic context by mechanisms outside the scope of this specification.]
This specification does not define any mechanism for creating or binding implementations of extension instructions or extension functions, and it is not required that implementations support any such mechanism. Such mechanisms, if they exist, are implementation-defined. Therefore, an XSLT stylesheet that must be portable between XSLT implementations cannot rely on particular extensions being available. XSLT provides mechanisms that allow an XSLT stylesheet to determine whether the implementation makes particular extensions available, and to specify what happens if those extensions are not available. If an XSLT stylesheet is careful to make use of these mechanisms, it is possible for it to take advantage of extensions and still retain portability.
[ERR XTSE0085] It is a static error to use a reserved namespace in the name of any extension function or extension instruction, other than a function or instruction defined in this specification or in a normatively referenced specification. It is a static error to use a prefix bound to a reserved namespace in the [xsl:]extension-element-prefixes attribute.
The set of functions that can be called from a FunctionCallXP within an XPath expression may include one or more extension functions. The expanded QName of an extension function always has a non-null namespace URI, which must not be the URI of a reserved namespace.
Note:
The definition of the term extension function is written to exclude user-written stylesheet functions, constructor functions for built-in and user-defined types, functions in the fn, math, map, and array namespaces, anonymous XPath inline functions, maps and arrays, and partial function applications (including partial applications of extension functions). It also excludes functions obtained by invoking XPath-defined functions such as load-xquery-module. The definition allows extension functions to be discovered at evaluation time (typically using function-lookup) rather than necessarily being known statically.
Technically, the definition of extension functions excludes anonymous functions obtained by calling or partially applying other extension functions. Since such functions are by their nature implementation-defined, they may however share some of the characteristics of extension functions.
Determines whether a particular function is or is not available for use. The function is particularly useful for calling within an [xsl:]use-when attribute (see 3.13.3 Conditional Element Inclusion) to test whether a particular extension function is available.
fn:function-available( | ||
$name | as (xs:string | xs:QName), | |
$arity | as xs:integer? | := () |
) as xs:boolean | ||
This function is deterministicFO, context-dependentFO, and focus-independentFO. It depends on namespaces, and known function signatures.
A function is said to be available within an XPath expression if it is present in the statically known function definitionsXP for that expression (see 5.3.1 Initializing the Static Context). Function definitions in the static context are uniquely identified by the name of the function (a QName) in combination with its arity range.
The value of $namemust be either an xs:QName, or a string containing an EQName. A lexical QName is expanded into an expanded QName using the namespace declarations in scope for the expression. If the value is an unprefixed lexical QName, then the standard function namespace is used in the expanded QName.
When the $arity argument is present and non-empty, the function-available function returns true if and only if there is an available function whose name matches the value of the $function-name argument and whose arity range includes the value of the $arity argument.
When the $arity argument is omitted or empty, the function-available function returns true if and only if there is at least one available function (with some arity) whose name matches the value of the $name argument.
When the containing expression is evaluated with XPath 1.0 compatibility mode set to true, the function-available function returns false in respect of a function name and arity for which no implementation is available (other than the fallback error function that raises a dynamic error whenever it is called). This means that it is possible (as in XSLT 1.0) to use logic such as the following to test whether a function is available before calling it:
<summary xsl:version="1.0"> <xsl:choose> <xsl:when test="function-available('my:summary')"> <xsl:value-of select="my:summary()"/> </xsl:when> <xsl:otherwise> <xsl:text>Summary not available</xsl:text> </xsl:otherwise> </xsl:choose> </summary>
[ERR XTDE1400] It is a dynamic error if the $name argument evaluates to a string that is not a valid EQName, or if the value is a lexical QName with a prefix for which no namespace declaration is present in the static context. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
The fact that a function with a given name is available gives no guarantee that any particular call on the function will be successful. For example, it is not possible to determine the types of the arguments expected.
The introduction of the function-lookup function in XPath 3.0 reduces the need for function-available, since function-lookup not only tests whether a function is available, but also returns a function item that enables it to be dynamically called.
If a function is present in the static context but with no useful functionality (for example, if the system has been configured for security reasons so that available-environment-variables returns no information), then function-available when applied to that function should return false.
It is not necessary that there be a direct equivalence between the results of function-available and function-lookup in all cases. For example, there may be extension functions whose side-effects are such that for security reasons, dynamic calls to the function are disallowed; function-lookup might then not provide access to the function. The main use-case for function-available, by contrast, is for use in [xsl:]use-when conditions to test whether static calls on the function are possible.
A stylesheet that is designed to use XSLT 2.0 facilities when running under an XSLT 2.0 or XSLT 3.0 processor, but to fall back to XSLT 1.0 capabilities when not, might be written using the code: <out xsl:version="2.0"> <xsl:choose> <xsl:when test="function-available('matches')"> <xsl:value-of select="matches(/doc/title, '[a-z]*')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="string-length( translate(/doc/title, 'abcdefghijklmnopqrstuvwxyz', '')) = 0"/> </xsl:otherwise> </xsl:choose> </out> Here an XSLT 2.0 or XSLT 3.0 processor will always take the | |
A stylesheet that is designed to use facilities in some future XSLT version when they are available, but to fall back to XSLT 2.0 or XSLT 3.0 capabilities when not, might be written using code such as the following. This hypothesizes the availability in some future version of a function <xsl:value-of select="pad(/doc/title, 10)" use-when="function-available('pad', 2)"/> <xsl:value-of select="concat(/doc/title, string-join( for $i in 1 to 10 - string-length(/doc/title) return ' ', ''))" use-when="not(function-available('pad', 2))"/> In this case the two-argument version of |
If the function name used in a FunctionCallXP within an XPath expression identifies an extension function, then to evaluate the FunctionCallXP, the processor will first evaluate each of the arguments in the FunctionCallXP. If the processor has information about the datatypes expected by the extension function, then it may perform any necessary type conversions between the XPath datatypes and those defined by the implementation language. If multiple extension functions are available with the same name, the processor may decide which one to invoke based on the number of arguments, the types of the arguments, or any other criteria. The result returned by the implementation is returned as the result of the function call, again after any necessary conversions between the datatypes of the implementation language and those of XPath. The details of such type conversions are outside the scope of this specification.
[ERR XTDE1420] It is a dynamic error if the arguments supplied to a call on an extension function do not satisfy the rules defined for that particular extension function, or if the extension function raises an error, or if the result of the extension function cannot be converted to an XPath value.
Note:
Implementations may also provide mechanisms allowing extension functions to raise recoverable dynamic errors, or to execute within an environment that treats some or all of the errors listed above as recoverable.
[ERR XTDE1425] When the containing element is processed with XSLT 1.0 behavior, it is a dynamic error to evaluate an extension function call if no implementation of the extension function is available.
Note:
When XSLT 1.0 behavior is not enabled, this is a static error [ERR XPST0017] XP40.
Note:
There is no prohibition on calling extension functions that have side-effects (for example, an extension function that writes data to a file). However, the order of execution of XSLT instructions is not defined in this specification, so the effects of such functions are unpredictable.
Implementations are not required to perform full validation of values returned by extension functions. It is an error for an extension function to return a string containing characters that are not permitted in XML, but the consequences of this error are implementation-defined. The implementation may raise an error, may convert the string to a string containing valid characters only, or may treat the invalid characters as if they were permitted characters.
Note:
The ability to execute extension functions represents a potential security weakness, since untrusted stylesheets may invoke code that has privileged access to resources on the machine where the processor executes. Implementations may therefore provide mechanisms that restrict the use of extension functions by untrusted stylesheets.
All observations in this section regarding the errors that can occur when invoking extension functions apply equally when invoking extension instructions.
An implementation may allow an extension function to return an object that does not have any natural representation in the XDM data model, whether as an atomic item, a node, or a function item. For example, an extension function sql:connect might return an object that represents a connection to a relational database; the resulting connection object might be passed as an argument to calls on other extension functions such as sql:insert and sql:select.
The way in which such objects are represented in the type system is implementation-defined. They might be represented by a completely new datatype, or they might be mapped to existing datatypes such as integer, string, or anyURI.
Used to control how a stylesheet behaves if a particular schema type is or is not available in the static context.
fn:type-available( | ||
$name | as (xs:string | xs:QName) | |
) as xs:boolean | ||
This function is deterministicFO, context-dependentFO, and focus-independentFO. It depends on namespaces, and schema definitions.
A schema type (that is, a simple type or a complex type) is said to be available within an XPath expression if it is a type definition that is present in the in-scope schema typesXP for that expression (see 5.3.1 Initializing the Static Context). This includes built-in types, types imported using xsl:import-schema, and extension types defined by the implementation.
The value of the $name argument must be either an xs:QName, or a string containing an EQName. The EQName is expanded into an expanded QName using the namespace declarations in scope for the expression. If the value is an unprefixed lexical QName, then the default namespace is used in the expanded QName.
The function returns true if and only if there is an available type whose name matches the value of the $name argument.
[ERR XTDE1428] It is a dynamic error if the argument evaluates to a string that is not a valid EQName, or if the value is a lexical QName with a prefix for which no namespace declaration is present in the static context. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
The type-available function is of limited use within an [xsl:]use-when expression, because the static context for the expression does not include any user-defined types.
It is possible to invoke a named template using an extension instruction, specifically, an element whose name matches the name of the named template. [Issue 168 30 September 2022]
[Definition: 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.] The namespace determines the semantics of the instruction.
Note:
Since an element that is a child of an xsl:stylesheet element is not occurring in a sequence constructor, user-defined data elements (see 3.7.4 User-defined Data Elements) are not extension elements as defined here, and nothing in this section applies to them.
In XSLT 4.0 it is possible to use extension instructions to invoke named templates: see 10.1.3 Invoking Named Templates using Extension Instructions.
A namespace is designated as an extension namespace by using an [xsl:]extension-element-prefixes attribute on an element in the stylesheet (see 3.4 Standard Attributes). The attribute must be in the XSLT namespace only if its parent element is not in the XSLT namespace. The value of the attribute is a whitespace-separated list of namespace prefixes. The namespace bound to each of the prefixes is designated as an extension namespace.
The default namespace (as declared by xmlns) may be designated as an extension namespace by including #default in the list of namespace prefixes.
A reserved namespace cannot be designated as an extension namespace: see [see ERR XTSE0085].
[ERR XTSE1430] It is a static error if there is no namespace bound to the prefix on the element bearing the [xsl:]extension-element-prefixes attribute or, when #default is specified, if there is no default namespace.
Note:
The prefix must be declared in a native namespace binding, not in a fixed namespace binding.
The designation of a namespace as an extension namespace is effective for the element bearing the [xsl:]extension-element-prefixes attribute and for all descendants of that element within the same stylesheet module.
Determines whether a particular instruction is or is not available for use. The function is particularly useful for calling within an [xsl:]use-when attribute (see 3.13.3 Conditional Element Inclusion) to test whether a particular extension instruction is available.
fn:element-available( | ||
$name | as (xs:string | xs:QName) | |
) as xs:boolean | ||
This function is deterministicFO, context-dependentFO, and focus-independentFO. It depends on namespaces.
The value of the $name argument must be either an xs:QName, or a string containing an EQName. If it is a lexical QName with a prefix, then it is expanded into an expanded QName using the namespace declarations in the static context of the expression. If there is a default namespace in scope, then it is used to expand an unprefixed lexical QName.
If the resulting expanded QName is in the XSLT namespace, the function returns true if and only if the local name matches the name of an XSLT element that is defined in this specification and implemented by the XSLT processor.
If the expanded QName has a null namespace URI, the element-available function will return false.
If the expanded QName is not in the XSLT namespace, the function returns true if and only if the processor has an external implementation available of an extension instruction with the given expanded QName. This applies whether or not the namespace has been designated as an extension namespace.
The term external implementation excludes the use of a named template as the instruction’s implementation. The function does not return true simply because the name matches the name of a named template.
If the processor does not have an implementation of a particular extension instruction available, and such an extension instruction is evaluated, then the processor must perform fallback for the element as specified in 25.2.324.2.3 Fallback. An implementation must not raise an error merely because the stylesheet contains an extension instruction for which no implementation is available.
[ERR XTDE1440] It is a dynamic error if the argument evaluates to a string that is not a valid EQName, or if the value is a lexical QName with a prefix for which no namespace declaration is present in the static context. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
For element names in the XSLT namespace:
This function can be useful to distinguish processors that implement XSLT 3.0 from processors that implement other (older or newer) versions of the specification, and to distinguish full implementations from incomplete implementations. (Incomplete implementations, of course, cannot be assumed to behave as described in this specification.)
In earlier versions of this specification, element-available was defined to return true only for elements classified as instructions. The distinction between instructions and other elements, however, is sometimes rather technical, and in XSLT 3.0 the effect of the function has therefore been aligned to do what its name might suggest.
If an instruction is recognized but offers no useful functionality (for example, if the system has been configured for security reasons so that xsl:evaluate always raises an error), then element-available when applied to that instruction should return false.
For element names in other namespaces:
The result of the element-available does not depend on whether or not the namespace of the supplied instruction name has been designated as an extension element namespace; it tests whether the instruction would be available if the namespace were designated as such.
<!-- Category: instruction -->
<xsl:fallback>
<!-- Content: sequence-constructor -->
</xsl:fallback>
The content of an xsl:fallback element is a sequence constructor, and when performing fallback, the value returned by the xsl:fallback element is the result of evaluating this sequence constructor.
When not performing fallback, evaluating an xsl:fallback element returns an empty sequence: the content of the xsl:fallback element is not evaluated.
There are two situations where a processor performs fallback: when an extension instruction that is not available is evaluated, and when an instruction in the XSLT namespace, that is not defined in XSLT 3.0, is evaluated within a region of the stylesheet for which forwards compatible behavior is enabled.
Note:
Fallback processing is not invoked in other situations, for example it is not invoked when an XPath expression uses unrecognized syntax or contains a call to an unknown function. To handle such situations dynamically, the stylesheet should call functions such as system-property and function-available to decide what capabilities are available.
[ERR XTDE1450] When a processor performs fallback for an extension instruction that is not recognized, if the instruction element has one or more xsl:fallback children, then the content of each of the xsl:fallback children must be evaluated; it is a dynamic error if it has no xsl:fallback children.
Note:
This is different from the situation with unrecognized XSLT elements. As explained in 3.10 Forwards Compatible Processing, an unrecognized XSLT element appearing within a sequence constructor is a static error unless (a) forwards compatible behavior is enabled, and (b) the instruction has an xsl:fallback child.
The output of a transformation includes a principal result and zero or more secondary results.
The way in which these results are delivered to an application is implementation-defined.
Serialization of results is described further in 2726 Serialization
A new serialization parameter escape-solidus is provided to control whether the character / is escaped as \/ by the JSON serialization method. [Issue 530 PR 534 9 June 2023]
The input to the serializer can be defined using the select attribute of xsl:result-document as an alternative to using a sequence constructor. [Issue 1534 ]
<!-- Category: instruction -->
<xsl:result-document
format? = { eqname }
href? = { uri }
select? = expression
validation? = "strict" | "lax" | "preserve" | "strip"
type? = eqname
method? = { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname }
allow-duplicate-names? = { boolean }
build-tree? = { boolean }
byte-order-mark? = { boolean }
cdata-section-elements? = { eqnames }
doctype-public? = { string }
doctype-system? = { string }
encoding? = { string }
escape-solidus? = { boolean }
escape-uri-attributes? = { boolean }
html-version? = { decimal }
include-content-type? = { boolean }
indent? = { boolean }
item-separator? = { string }
json-lines? = { boolean }
json-node-output-method? = { "xml" | "html" | "xhtml" | "text" | eqname }
media-type? = { string }
normalization-form? = { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken }
omit-xml-declaration? = { boolean }
parameter-document? = { uri }
standalone? = { boolean | "omit" }
suppress-indentation? = { eqnames }
undeclare-prefixes? = { boolean }
use-character-maps? = eqnames
output-version? = { nmtoken } >
<!-- Content: sequence-constructor -->
</xsl:result-document>
The xsl:result-document instruction is used to create a secondary result.
The select attribute and the contained sequence constructor are mutually exclusive; if the select attribute is present then the sequence constructor must be empty, and if the sequence constructor is non-empty then the select attribute must be absent [see ERR XTSE3185]. The value of the select attribute or the immediate result of the contained sequence constructor is referred to as the raw result.
As with the principal result of the transformation, a secondary result may be delivered to the calling application in three ways (see 2.3.6 Post-processing the Raw Result):
The raw result may be delivered as is.
The raw result may be used to construct a final result tree by invoking the process of sequence normalizationSER30.
The raw result may be serialized to a sequence of octets (which may then, optionally, be saved to a persistent storage location).
The decision whether or not to serialize the raw result depends on the processor and on the way it is invoked. This is implementation-defined, and it is not controlled by anything in the stylesheet.
If the result is not serialized, then the decision whether to return the raw result or to construct a tree depends on the effective value of the build-tree attribute. If the effective value of the build-tree attribute is yes, then a final result tree is created by invoking the process of sequence normalizationSER30. Conversely, if the result is serialized, then the decision whether or not to construct a tree depends on the choice of serialization method, and the build-tree attribute is then ignored. For example, with method="xml" a tree is always constructed, whereas with method="json" a tree is never constructed. [XSLT 3.0 Erratum E14, bug 30208].
The xsl:result-document instruction defines a URI that may be used to identify the secondary result. The instruction may optionally specify the output format to be used for serializing the result.
Technically, the result of evaluating the xsl:result-document instruction is an empty sequence. This means it does not contribute anything to the result of the sequence constructor it is part of.
The effective value of the format attribute, if specified, must be an EQName. The value is expanded using the namespace declarations in scope for the xsl:result-document element. The resulting expanded QNamemust match the expanded QName of a named output definition in the stylesheet. This identifies the xsl:output declaration that will control the serialization of the final result tree (see 2726 Serialization), if the result tree is serialized. If the format attribute is omitted, the unnamed output definition is used to control serialization of the result tree.
[ERR XTDE1460] It is a dynamic error if the effective value of the format attribute is not a valid EQName, or if it does not match the expanded QName of an output definition in the containing package. If the processor is able to detect the error statically (for example, when the format attribute contains no curly brackets), then the processor may optionally raise this as a static error.
Note:
The only way to select the unnamed output definition is to omit the format attribute.
The parameter-document attribute allows serialization parameters to be supplied in an external document. The external document must contain an output:serialization-parameters element with the format described in Section 3.1 Setting Serialization Parameters by Means of a Data Model Instance SER30, and the parameters are interpreted as described in that specification.
If present, the effective value of the URI supplied in the parameter-document attribute is dereferenced, after resolution against the base URI of the xsl:result-document element if it is a relative reference. The parameter document should be read during run-time evaluation of the stylesheet. If the location of the stylesheet at development time is different from the deployed location, any relative reference should be resolved against the deployed location. A serialization error occurs if the result of dereferencing the URI is ill-formed or invalid; but if no document can be found at the specified location, the attribute should be ignored.
A serialization parameter specified in the parameter-document takes precedence over a value supplied directly as an attribute of xsl:result-document, which in turn takes precedence over a value supplied in the selected output definition, except that the values of the cdata-section-elements and suppress-indentation attributes are merged in the same way as when multiple xsl:output declarations are merged.
The attributes method, allow-duplicate-names, build-tree, byte-order-markcdata-section-elements, doctype-public, doctype-system, encoding, escape-solidusescape-uri-attributes, html-version, indent, item-separator, json-lines, json-node-output-method, media-type, normalization-form, omit-xml-declaration, standalone, suppress-indentation, undeclare-prefixes, use-character-maps, and output-version may be used to override attributes defined in the selected output definition.
With the exception of use-character-maps, these attributes are all defined as attribute value templates, so their values may be set dynamically. For any of these attributes that is present on the xsl:result-document instruction, the effective value of the attribute overrides or supplements the corresponding value from the output definition. This works in the same way as when one xsl:output declaration overrides another. Some of the attributes have more specific rules:
In the case of cdata-section-elements and suppress-indentation, the value of the serialization parameter is the union of the expanded names of the elements named in this instruction and the elements named in the selected output definition.
In the case of use-character-maps, the character maps referenced in this instruction supplement and take precedence over those defined in the selected output definition.
In the case of doctype-public and doctype-system, setting the effective value of the attribute to a zero-length string has the effect of overriding any value for these attributes obtained from the output definition. The corresponding serialization parameter is not set (is “absent”).
In the case of item-separator, setting the effective value of the attribute to the special value "#absent" has the effect of overriding any value for this attribute obtained from the output definition. The corresponding serialization parameter is not set (is “absent”). It is not possible to set the value of the serialization parameter to the literal 7-character string "#absent".
In all other cases, the effective value of an attribute actually present on this instruction takes precedence over the value defined in the selected output definition.
Note:
In the case of the attributes method, cdata-section-elements, suppress-indentation, and use-character-maps, the effective value of the attribute contains a space-separated list of EQNames. If any of these is a lexical QName with a prefix, the prefix is expanded using the applicable static namespaces for the xsl:result-document element. In the case of cdata-section-elements and suppress-indentation, an unprefixed element name is expanded using the default namespace. In the case of the method attribute, if the method is not one of the system-defined methods (xml, html, xhtml, text, json, adaptive) then the expanded name must have a non-absent namespace.
The output-version attribute on the xsl:result-document instruction overrides the version attribute on xsl:output (it has been renamed because version is available with a different meaning as a standard attribute: see 3.4 Standard Attributes). In all other cases, attributes correspond if they have the same name.
There are some serialization parameters that apply to some output methods but not to others. For example, the indent attribute has no effect on the text output method. If a value is supplied for an attribute that is inapplicable to the output method, its value is not passed to the serializer. The processor may validate the value of such an attribute, but is not required to do so.
The item-separator serialization parameter is used when the raw result is used to construct a result tree by applying sequence normalization, and it is also used when the result tree is serialized. For example, if the sequence constructor delivers a sequence of integers, and the text serialization method is used, then the result of serialization will be a string obtained by converting each integer to a string, and separating the strings using the defined item-separator.
The href attribute is optional. The default value is the zero-length string. The effective value of the attribute must be a URI Reference, which may be absolute or relative. If it is relative, then it is resolved against the base output URI. There may be implementation-defined restrictions on the form of absolute URI that may be used, but the implementation is not required to enforce any restrictions. Any valid relative URI reference must be accepted. Note that the zero-length string is a valid relative URI reference.
If the implementation provides an API to access secondary results, then it must allow a secondary result to be identified by means of the absolutized value of the href attribute. In addition, if a final result tree is constructed (that is, if the effective value of build-tree is yes), then this value is used as the base URI of the document node at the root of the final result tree.
Note:
The base URI of the final result tree is not necessarily the same thing as the URI of its serialized representation on disk, if any. For example, a server (or browser client) might store final result trees only in memory, or in an internal disk cache. As long as the processor satisfies requests for those URIs, it is irrelevant where they are actually written on disk, if at all.
Note:
It will often be the case that one final result tree contains links to another final result tree produced during the same transformation, in the form of a relative URI reference. The mechanism of associating a URI with a final result tree has been chosen to allow the integrity of such links to be preserved when the trees are serialized.
As well as being potentially significant in any API that provides access to final result trees, the base URI of the new document node is relevant if the final result tree, rather than being serialized, is supplied as input to a further transformation.
The optional attributes type and validation may be used on the xsl:result-document instruction to validate the contents of a final result tree, and to determine the type annotation that elements and attributes within the final result tree will carry. The permitted values and their semantics are described in 26.4.225.4.2 Validating Document Nodes. Any such validation is applied to the document node produced as the result of sequence normalizationSER30. If sequence normalization does not take place (typically because the raw result is delivered to the application directly, or because the selected serialization method does not involve sequence normalization) then the validation and type attributes are ignored.
Note:
Validation applies after inserting item separators as determined by the item-separator serialization parameter, and an inappropriate choice of item-separator may cause the result to become invalid.
A processormay allow a final result tree to be serialized. Serialization is described in 2726 Serialization. However, an implementation (for example, a processor running in an environment with no access to writable filestore) is not required to support the serialization of final result trees. An implementation that does not support the serialization of final result trees may ignore the format attribute and the serialization attributes. Such an implementation must provide the application with some means of access to the (un-serialized) result tree, using its URI to identify it.
Implementations may provide additional mechanisms, outside the scope of this specification, for defining the way in which final result trees are processed. Such mechanisms may make use of the XSLT-defined attributes on the xsl:result-document and/or xsl:output elements, or they may use additional elements or attributes in an implementation-defined namespace.
The following example takes an XHTML document as input, and breaks it up so that the text following each <h1> element is included in a separate document. A new document toc.html is constructed to act as an index:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xsl:output name="toc-format" method="xhtml" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/> <xsl:output name="section-format" method="xhtml" indent="no" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/> <xsl:template match="/"> <xsl:result-document href="toc.html" format="toc-format" validation="strict"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Table of Contents</title></head> <body> <h1>Table of Contents</h1> <xsl:for-each select="/*/xhtml:body/(*[1] | xhtml:h1)"> <p> <a href="section{position()}.html"> <xsl:value-of select="."/> </a> </p> </xsl:for-each> </body> </html> </xsl:result-document> <xsl:for-each-group select="/*/xhtml:body/*" group-starting-with="xhtml:h1"> <xsl:result-document href="section{position()}.html" format="section-format" validation="strip"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title><xsl:value-of select="."/></title></head> <body> <xsl:copy-of select="current-group()"/> </body> </html> </xsl:result-document> </xsl:for-each-group> </xsl:template> </xsl:stylesheet>
xsl:result-documentThere are restrictions on the use of the xsl:result-document instruction, designed to ensure that the results are fully interoperable even when processors optimize the sequence in which instructions are evaluated. Informally, the restriction is that the xsl:result-document instruction can only be used while writing a final result tree, not while writing to a temporary tree or a sequence. This restriction is defined formally as follows.
[Definition: Each instruction in the stylesheet is evaluated in one of two possible output states: final output state or temporary output state.]
[Definition: The first of the two output states is called final output state. This state applies when instructions are writing to a final result tree.]
[Definition: 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.]
The instructions in the initial named template are evaluated in final output state. An instruction is evaluated in the same output state as its calling instruction, except that xsl:variable, xsl:param, xsl:with-param, xsl:function, xsl:key, xsl:sort, xsl:accumulator-rule, and xsl:merge-key always evaluate the instructions in their contained sequence constructor in temporary output state.
[ERR XTDE1480] It is a dynamic error to evaluate the xsl:result-document instruction in temporary output state.
[ERR XTDE1490] It is a dynamic error for a transformation to generate two or more final result trees with the same URI.
Note:
Note, this means that it is an error to evaluate more than one xsl:result-document instruction that omits the href attribute, or to evaluate any xsl:result-document instruction that omits the href attribute if an initial final result tree is created implicitly.
In addition, an implementation may raise this error if it is able to detect that two or more final result trees are generated with different URIs that refer to the same physical resource.
[ERR XTDE1500] It is a dynamic error for a stylesheet to write to an external resource and read from the same resource during a single transformation, if the same absolute URI is used to access the resource in both cases.
In addition, an implementation may raise this error if it is able to detect that a transformation writes to a resource and reads from the same resource using different URIs that refer to the same physical resource. Note that if the error is not detected, it is implementation-dependent whether the document that is read from the resource reflects its state before or after the result tree is written.
[Definition: The current output URI is the URI associated with the principal result or secondary result that is currently being written.]
Returns the value of the current output URI.
fn:current-output-uri() as xs:anyURI? |
This function is deterministicFO, focus-independentFO, and context-dependentFO.
On initial invocation of a stylesheet component, the current output uri is set to the base output URI.
During execution of an xsl:result-document instruction with an href attribute, the current output URI changes to the absolute URI obtained by resolving the effective value of the href attribute against the base output URI.
The current output URI is cleared (set to absent) while evaluating stylesheet functions, dynamic function calls, evaluation of global variables, stylesheet parameters, and patterns. If the function is called when the current output URI is absent, the function returns the empty sequence.
The current output URI may also be absent in the event that a stylesheet is invoked without supplying a base output URI.
The current output URI is not cleared when evaluating a local variable, even though xsl:result-document cannot be used while evaluating a local variable. The reason for this is to allow the value of current-output-uri to be set as the value of a tunnel parameter, so that the original base output URI is accessible even when writing nested result documents.
The rules concerning the compatibility of schemas imported by different packages have been clarified. It is now explicitly stated that instructions that trigger validation must use the imported schema of the package in which validation is invoked. This differs from the current practice of some XSLT 3.0 processors, which may use (for example) a schema formed from the union of the imported schemas in all packages. [Issue 451 PR 635 24 October 2023]
The rules concerning the interpretation of xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes have been tightened up. [Issue 729 PR 1254 8 June 2024]
It is possible to control the type annotation applied to individual element and attribute nodes as they are constructed. This is done using the type and validation attributes of the xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, xsl:document, and xsl:result-document instructions, or the xsl:type and xsl:validation attributes of a literal result element. The same attributes are used on xsl:source-document and xsl:merge-source to control validation of input documents.
The [xsl:]type attribute is used to request validation of an element or attribute against a specific simple or complex type defined in a schema. The [xsl:]validation attribute is used to request validation against the global element or attribute declaration whose name matches the name of the element or attribute being validated.
The [xsl:]type and [xsl:]validation attributes are mutually exclusive. Both are optional, but if one is present then the other must be omitted. If both attributes are omitted, the effect is the same as specifying the validation attribute with the value specified in the [xsl:]default-validation attribute of the innermost containing element having such an attribute; if this is not specified, the effect is the same as specifying validation="strip".
The [xsl:]default-validation attribute defines the default value of the validation attribute of all xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, xsl:document, and xsl:result-document instructions, and of the xsl:validation attribute of all literal result elements, appearing as descendants of the element on which the attribute appears, unless there is an inner element that defines a different default. This default does not extend to included or imported stylesheet modules or used packages. If the attribute is omitted, the default is strip. The permitted values are preserve and strip.
The default-validation attribute on the outermost element of the principal stylesheet module of the top-level package also determines the validation applied to the implicit final result tree created in the absence of an xsl:result-document instruction. [XSLT 3.0 Erratum E15, bug 30211].
The [xsl:]default-validation attribute has no effect on the xsl:source-document and xsl:merge-source elements, which perform no validation unless explicitly requested.
[ERR XTSE1505] It is a static error if both the [xsl:]type and [xsl:]validation attributes are present on the xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, xsl:document, xsl:result-document, xsl:source-document, or xsl:merge-source elements, or on a literal result element.
Validation always uses the schema associated with the containing package (that is, the in-scope schema definitionsXP from the static context of the instruction that invokes validation).
Note:
A stylesheet might take as its primary input a document conforming to schema X, and produce as its primary output a document conforming to schema Y. To be sure that the output is indeed valid against schema Y, the safest course of action is to evaluate an xsl:result-document instruction within a package that imports schema Y and nothing else. Otherwise, if the validation occurs within a module that imports both X and Y, the outcome of validation might differ because of the differences between the two schemas.
The detailed rules for validation vary depending on the kind of node being validated. The rules for element and attribute nodes are given in 26.4.125.4.1 Validating Constructed Elements and Attributes, while those for document nodes are given in 26.4.225.4.2 Validating Document Nodes.
[xsl:]validation AttributeThe [xsl:]validation attribute defines the validation action to be taken. It determines not only the type annotation of the node that is constructed by the relevant instruction itself, but also the type annotations of all element and attribute nodes that have the constructed node as an ancestor. Conceptually, the validation requested for a child element or attribute node is applied before the validation requested for its parent element. For example, if the instruction that constructs a child element specifies validation="strict", this will cause the child element to be checked against an element declaration, but if the instruction that constructs its parent element specifies validation="strip", then the final effect will be that the child node is annotated as xs:untyped.
In the paragraphs below, the term contained nodes means the elements and attributes that have the newly constructed node as an ancestor.
The value strip indicates that the new node and each of the contained nodes will have the type annotationxs:untyped if it is an element, or xs:untypedAtomic if it is an attribute. Any previous type annotation present on a contained element or attribute node (for example, a type annotation that is present on an element copied from a source document) is also replaced by xs:untyped or xs:untypedAtomic as appropriate. The typed value of the node is changed to be the same as its string value, as an instance of xs:untypedAtomic. In the case of elements the nilled property is set to false. The values of the is-id and is-idrefs properties are unchanged. Schema validation is not invoked.
The value preserve indicates that nodes that are copied will retain their type annotations, but nodes whose content is newly constructed will be annotated as xs:anyType in the case of elements, or xs:untypedAtomic in the case of attributes. Schema validation is not invoked. The detailed effect depends on the instruction:
In the case of xsl:element and literal result elements, the new element has a type annotation of xs:anyType, and the type annotations of contained nodes are retained unchanged.
The nilled, is-id and is-idrefs properties on the new element are set to false.
In the case of xsl:attribute, the effect is exactly the same as specifying validation="strip": that is, the new attribute will have the type annotation xs:untypedAtomic.
The is-id and is-idrefs properties on the new attribute are set to false.
In the case of xsl:copy-of, all the nodes that are copied will retain their type annotations unchanged. The values of their nilled, is-id and is-idrefs properties are also unchanged.
In the case of xsl:copy, the effect depends on the kind of node being copied.
Where the node being copied is an attribute, the copied attribute will retain its type annotation and the values of its is-id and is-idrefs properties.
Where the node being copied is an element, the copied element will have a type annotation of xs:anyType (because this instruction does not copy the content of the element, it would be wrong to assume that the type is unchanged); but any contained nodes will have their type annotations retained in the same way as with xsl:element. The values of the nilled, is-id, and is-idrefs properties are handled in the same way as xsl:element.
The value strict indicates that type annotations are established by performing strict schema validity assessment on the element or attribute node created by this instruction as follows:
In the case of an element, a top-level element declaration is identified whose local name and namespace (if any) match the name of the element, and schema-validity assessment is carried out according to the rules defined in [XML Schema Part 1] (section 3.3.4 “Element Declaration Validation Rules”, validation rule “Schema-Validity Assessment (Element)”, clauses 1.1 and 2, using the top-level element declaration as the “declaration stipulated by the processor”, which is mentioned in clause 1.1.1.1). The element is considered valid if the result of the schema validity assessment is a PSVI in which the relevant element node has a validity property whose value is valid. If there is no matching element declaration, or if the element is not considered valid, the transformation fails [see ERR XTTE1510], [see ERR XTTE1512]. In effect this means that the element being validated must be declared using a top-level declaration in the schema, and must conform to its declaration. The process of validation applies recursively to contained elements and attributes to the extent required by the schema definition.
Note:
It is not an error if the identified type definition is a simple type, although [XML Schema Part 1] does not define explicitly that this case is permitted.
In the case of an attribute, a top-level attribute declaration is identified whose local name and namespace (if any) match the name of the attribute, and schema-validity assessment is carried out according to the rules defined in [XML Schema Part 1] (section 3.2.4 “Attribute Declaration Validation Rules”, validation rule “Schema-Validity Assessment (Attribute)”). The attribute is considered valid if the result of the schema validity assessment is a PSVI in which the relevant attribute node has a validity property whose value is valid. If the attribute is not considered valid, the transformation fails [see ERR XTTE1510]. In effect this means that the attribute being validated must be declared using a top-level declaration in the schema, and must conform to its declaration.
The schema components used to validate an element or attribute may be located in any way described by [XML Schema Part 1] (see section 4.3.2, How schema documents are located on the Web). The components in the schema constructed from the synthetic schema document (see 3.15 Importing Schema Components) will always be available for validating constructed nodes; if additional schema components are needed, they may be located in other ways, for example implicitly from knowledge of the namespace in which the elements and attributes appear, or using the xsi:schemaLocation attribute of elements within the tree being validated (see 26.4.1.325.4.1.3 The xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes).
The type annotations on the resulting nodes, as well as the values of their is-id, is-idrefs, and nilled properties, are defined by the rules in Section 3.3 Construction from a PSVI DM31.
If no validation is performed for a node, which can happen when the schema specifies lax or skip validation for that node or for a subtree, then the node is annotated as xs:anyType in the case of an element, and xs:untypedAtomic in the case of an attribute.
The value lax has the same effect as the value strict, except that whereas strict validation fails if there is no matching top-level element declaration or if the outcome of validity assessment is a validity property of invalid or notKnown, lax validation fails only if the outcome of validity assessment is a validity property of invalid. That is, lax validation does not cause a type error when the outcome is notKnown.
In practice this means that the element or attribute being validated must conform to its declaration if a top-level declaration is available. If no such declaration is available, then the element or attribute is not validated, but its attributes and children are validated, again with lax validation. Any nodes whose validation outcome is a validity property of notKnown are annotated as xs:anyType in the case of an element, and xs:untypedAtomic in the case of an attribute.
The type annotations on the resulting nodes, as well as the values of their is-id, is-idrefs, and nilled properties, are defined by the rules in Section 3.3 Construction from a PSVI DM31.
Note:
When the parent element lacks a declaration, the XML Schema specification defines the recursive checking of children and attributes as optional. For this specification, this recursive checking is required.
Note:
If an element that is being validated has an xsi:type attribute, then the value of the xsi:type attribute will be taken into account when performing the validation. However, the presence of an xsi:type attribute will not of itself cause an element to be validated: if validation against a named type is required, as distinct from validation against a top-level element declaration, then it must be requested using the XSLT [xsl:]type attribute on the instruction that invokes the validation, as described in section 26.4.1.225.4.1.2 Validation using the [xsl:]type Attribute
[ERR XTTE1510] If the validation attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, or xsl:result-document instruction, or the xsl:validation attribute of a literal result element, has the effective valuestrict, and schema validity assessment concludes that the validity of the element or attribute is invalid or unknown, a type error occurs. As with other type errors, the error may be raised statically if it can be detected statically.
[ERR XTTE1512] If the validation attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, or xsl:result-document instruction, or the xsl:validation attribute of a literal result element, has the effective valuestrict, and there is no matching top-level declaration in the schema, then a type error occurs. As with other type errors, the error may be raised statically if it can be detected statically.
[ERR XTTE1515] If the validation attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, or xsl:result-document instruction, or the xsl:validation attribute of a literal result element, has the effective valuelax, and schema validity assessment concludes that the element or attribute is invalid, a type error occurs. As with other type errors, the error may be raised statically if it can be detected statically.
Note:
No mechanism is provided to validate an element or attribute against a local declaration in a schema. Such validation can usually be achieved by applying validation to a containing element for which a top-level element declaration exists.
[xsl:]type AttributeThe [xsl:]type attribute takes as its value an EQNameXP. If it is a lexical QName with no prefix, it is expanded using the default namespace for types. This must be the name of a type definition included in the in-scope schema components for the stylesheet.
If the [xsl:]type attribute is present, then the newly constructed element or attribute is validated against the type definition identified by this attribute.
In the case of an element, schema-validity assessment is carried out according to the rules defined in [XML Schema Part 1] (section 3.3.4 “Element Declaration Validation Rules”, validation rule “Schema-Validity Assessment (Element)”, clauses 1.2 and 2), using this type definition as the “processor-stipulated type definition”. The element is considered valid if the result of the schema validity assessment is a PSVI in which the relevant element node has a validity property whose value is valid.
In the case of an attribute, the attribute is considered valid if (in the terminology of XML Schema) the attribute’s normalized value is locally valid with respect to that type definition according to the rules for “String Valid” ([XML Schema Part 1], section 3.14.4). (Normalization here refers to the process of normalizing whitespace according to the rules of the whiteSpace facet for the datatype).
If the element or attribute is not considered valid, as defined above, the transformation fails [see ERR XTTE1540].
If an element node is validated against the type xs:untyped, the effect is the same as specifying validation="strip": that is, the elements and attributes in the subtree rooted at the target element are copied with a type annotation of xs:untyped or xs:untypedAtomic respectively.
If an element or attribute node is validated against the type xs:untypedAtomic, the effect is the same as specifying [xsl:]type="xs:string" except that when validation succeeds, the returned element or attribute has a type annotation of xs:untypedAtomic. Validation fails in the case of an element with element children.
[ERR XTSE1520] It is a static error if the value of the type attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, xsl:document, xsl:result-document, xsl:source-document, or xsl:merge-source instruction, or the xsl:type attribute of a literal result element, is not a valid QName, or if it uses a prefix that is not defined in the applicable static namespaces of the containing instruction, or if the QName is not the name of a type definition included in the in-scope schema components for the package. [XSLT 3.0 Erratum E20, bug 30234]
[ERR XTSE1530] It is a static error if the value of the type attribute of an xsl:attribute instruction refers to a complex type definition.
[ERR XTTE1535] It is a type error if the value of the type attribute of an xsl:copy or xsl:copy-of instruction refers to a complex type definition and one or more of the items being copied is an attribute node.
[ERR XTTE1540] It is a type error if an [xsl:]type attribute is defined for a constructed element or attribute, and the outcome of schema validity assessment against that type is that the validity property of that element or attribute information item is other than valid.
Note:
Like other type errors, this error may be raised statically if it can be detected statically. For example, the instruction <xsl:attribute name="dob" type="xs:date">1999-02-29</xsl:attribute> may result in a static error being raised. If the error is not raised statically, it will be raised when the instruction is evaluated.
xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributesIt is implementation-defined whether the validity assessment process takes account of any xsi:schemaLocation or xsi:noNamespaceSchemaLocation attributes in the tree being validated. If it does so, then it should adhere to the following rules:
Any schema loaded using these attributes must be compatibleDM with the schema in the static context from which validation is invoked.
Any schema loaded using these attributes must not override or redefine any schema components in the static context.
Any schema components loaded using this mechanism must be used for this validity assessment only, and must not affect the outcome of any subsequent validity assessments of other documents.
Note:
A processor may choose to cache such schema components but the existence of such a cache should only affect performance, not the validation outcome.
A consequence of validating a document using schema components that are not in the static context is that nodes may be annotated with types that are not in the static context. But the rules for schema compatibilityDM mean that this is not a problem.
As well as checking for validity against the schema, the validity assessment process causes type annotations to be associated with element and attribute nodes. If default values for elements or attributes are defined in the schema, the validation process will where necessary create new nodes containing these default values.
Validation of an element or attribute node only takes into account constraints on the content of the element or attribute. Validation rules affecting the document as a whole are not applied. Specifically, this means:
The validation rule “Validation Root Valid (ID/IDREF)” is not applied. This means that validation will not fail if there are non-unique ID values or dangling IDREF values in the subtree being validated.
The validation rule “Validation Rule: Identity-constraint Satisfied” should be applied.
There is no check that the document contains unparsed entities whose names match the values of nodes of type xs:ENTITY or xs:ENTITIES. (XSLT 3.0 provides no facility to construct unparsed entities within a tree.)
With these caveats, validating a newly constructed element, using strict or lax validation, is equivalent to the following steps:
The element is serialized to textual XML form, according to the rules defined in [XSLT and XQuery Serialization] using the XML output method, with all parameters defaulted. Note that this process discards any existing type annotations.
The resulting XML document is parsed to create an XML Information Set (see [XML Information Set].)
The Information Set produced in the previous step is validated according to the rules in [XML Schema Part 1]. The result of this step is a Post-Schema Validation Infoset (PSVI). If the validation process is not successful (as defined above), a type error is raised.
The PSVI produced in the previous step is converted back into the XDM data model by the mapping described in [XDM 3.0] (Section 3.3.1 Mapping PSVI Additions to Node Properties DM30). This process creates nodes with simple or complex type annotations based on the types established during schema validation.
The above process must be done in such a way that the base URI property of every node in the resulting XDM tree is the same as the base URI property of the corresponding node in the input tree.
Note:
As an alternative to steps 1 and 2, the XDM tree may be converted to an Infoset directly, using the mapping rules given for each kind of node in [XDM 3.0] (Section 6).
Validating an attribute using strict or lax validation requires a modified version of this procedure. A copy of the attribute is first added to an element node that is created for the purpose, and namespace fixup (see 5.8.3 Namespace Fixup) is performed on this element node. The name of this element is of no consequence, but it must be the same as the name of a synthesized element declaration of the form:
<xs:element name="E"> <xs:complexType> <xs:sequence/> <xs:attribute ref="A"/> </xs:complexType> </xs:element>
where A is the name of the attribute being validated.
This synthetic element is then validated using the procedure given above for validating elements, and if it is found to be valid, a copy of the validated attribute is made, retaining its type annotation, but detaching it from the containing element (and thus, from any namespace nodes).
The XDM data model does not permit an attribute node with no parent to have a typed value that includes a namespace-qualified name, that is, a value whose type is derived from xs:QName or xs:NOTATION. This restriction is imposed because these types rely on the namespace nodes of a containing element to resolve namespace prefixes. Therefore, it is an error to validate a parentless attribute against such a type. This affects the instructions xsl:attribute, xsl:copy, and xsl:copy-of.
[ERR XTTE1545] A type error occurs if a type or validation attribute is defined (explicitly or implicitly) for an instruction that constructs a new attribute node, if the effect of this is to cause the attribute value to be validated against a type that is derived from, or constructed by list or union from, the primitive types xs:QName or xs:NOTATION.
It is possible to apply validation to a document node. This happens when a new document node is constructed by one of the XSLT elements xsl:source-document, xsl:merge-source, xsl:document, xsl:result-document, xsl:copy, or xsl:copy-of, and this element has a type attribute, or a validation attribute with the value strict or lax.
Document-level validation is not applied to the document node that is created implicitly when a variable-binding element has no select attribute and no as attribute (see 9.4 Creating Implicit Document Nodes). This is equivalent to using validation="preserve" on xsl:document: nodes within such trees retain their type annotation. Similarly, validation is not applied to document nodes created using xsl:message or xsl:assert.
The values validation="preserve" and validation="strip" do not request validation. In the first case, all element and attribute nodes within the tree rooted at the new document node retain their type annotations. In the second case, elements within the tree have their type annotation set to xs:untyped, while attributes have their type annotation set to xs:untypedAtomic.
When validation is requested for a document node (that is, when validation is set to strict or lax, or when a type attribute is present), the following processing takes place:
[ERR XTTE1550] A type error occurs unless the children of the document node comprise exactly one element node, no text nodes, and zero or more comment and processing instruction nodes, in any order.
The single element node child is validated, using the supplied values of the validation and type attributes, as described in 26.4.125.4.1 Validating Constructed Elements and Attributes.
Note:
The type attribute on xsl:source-document, xsl:document and xsl:result-document, and on xsl:copy and xsl:copy-of when copying a document node, thus refers to the required type of the element node that is the only element child of the document node. It does not refer to the type of the document node itself.
The validation rule “Validation Root Valid (ID/IDREF)” is applied to the single element node child of the document node. This means that validation will fail if there are non-unique ID values or dangling IDREF values in the document tree.
Identity constraints, as defined in section 3.11 of [XML Schema Part 1], are checked. (This refers to constraints defined using xs:unique, xs:key, and xs:keyref.)
There is no check that the tree contains unparsed entities whose names match the values of nodes of type xs:ENTITY or xs:ENTITIES. This is because there is no facility in XSLT 3.0 to create unparsed entities in a result tree. It is possible to add unparsed entity declarations to the result document by referencing a suitable DOCTYPE during serialization.
All other children of the document node (comments and processing instructions) are copied unchanged.
[ERR XTTE1555] It is a type error if, when validating a document node, document-level constraints (such as ID/IDREF constraints) are not satisfied.
xml:id attributesThis section provides a non-normative summary of the effect of validation on attributes named xml:id. The normative rules can be inferred from rules given elsewhere in this section.
When an attribute named xml:id is encountered in the course of validation:
A validation error occurs if it the attribute is not lexically valid against type xs:ID.
The typed value of the attribute is whitespace-normalized.
The attribute is labeled with type annotation xs:ID.
The attribute acquires the is-id property.
The previous rule applies whether validation is strict, lax, or by type; validation will never fail (or be skipped) on the grounds that no global attribute declaration named xsl:id is available.
Checking xml:id attributes for uniqueness happens if and only if validation is applied at the level of a document node.
A processormay output a final result tree as a sequence of octets, although it is not required to be able to do so (see 2827 Conformance). This process is described as serialization. Stylesheet authors can use xsl:output declarations to specify how they wish result trees to be serialized. If a processor serializes a final result tree, it must do so as specified by these declarations.
The rules governing the output of the serializer are defined in [XSLT and XQuery Serialization]. The serialization is controlled using a number of serialization parameters. The values of these serialization parameters may be set within the stylesheet, using the xsl:output, xsl:result-document, and xsl:character-map declarations.
xsl:output declaration<!-- Category: declaration -->
<xsl:output
name? = eqname
method? = "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname
allow-duplicate-names? = boolean
build-tree? = boolean
byte-order-mark? = boolean
cdata-section-elements? = eqnames
doctype-public? = string
doctype-system? = string
encoding? = string
escape-solidus? = boolean
escape-uri-attributes? = boolean
html-version? = decimal
include-content-type? = boolean
indent? = boolean
item-separator? = string
json-lines? = boolean
json-node-output-method? = "xml" | "html" | "xhtml" | "text" | eqname
media-type? = string
normalization-form? = "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken
omit-xml-declaration? = boolean
parameter-document? = uri
standalone? = boolean | "omit"
suppress-indentation? = eqnames
undeclare-prefixes? = boolean
use-character-maps? = eqnames
version? = nmtoken />
The xsl:output declaration is optional; if used, it must always appear as a top-level element within a stylesheet module.
A stylesheet may contain multiple xsl:output declarations and may include or import stylesheet modules that also contain xsl:output declarations. The name of an xsl:output declaration is the value of its name attribute, if any.
[Definition: All the xsl:output declarations within a package 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.]
An output definition is scoped to a package. If this is a library package the output definition applies only to xsl:result-document instructions within the same package. If it is the top-level package, the output definition applies to xsl:result-document instructions within the same package and also to the implicit final result tree.
A stylesheet always includes an unnamed output definition; in the absence of an unnamed xsl:output declaration, the unnamed output definition is equivalent to the one that would be used if the stylesheet contained an xsl:output declaration having no attributes.
A named output definition is used when its name matches the format attribute used in an xsl:result-document element. The unnamed output definition is used when an xsl:result-document element omits the format attribute. It is also used when serializing the principal result. .
All the xsl:output elements making up an output definition are effectively merged. For those attributes whose values are namespace-sensitive, the merging is done after lexical QNames have been converted into expanded QNames. For the cdata-section-elements and suppress-indentation attributes, the output definition uses the union of the values from all the constituent xsl:output declarations. For the use-character-maps attribute, the output definition uses the concatenation of the sequences of expanded QNames values from all the constituent xsl:output declarations, taking them in order of increasing import precedence, or where several have the same import precedence, in declaration order. For other attributes, the output definition uses the value of that attribute from the xsl:output declaration with the highest import precedence.
The parameter-document attribute allows serialization parameters to be supplied in an external document. The external document must contain an output:serialization-parameters element with the format described in Section 3.1 Setting Serialization Parameters by Means of a Data Model Instance SER30, and the parameters are interpreted as described in that specification.
If present, the URI supplied in the parameter-document attribute is dereferenced, after resolution against the base URI of the xsl:output element if it is a relative reference. The parameter document should be read during static analysis of the stylesheet. A serialization error occurs if the result of dereferencing the URI is ill-formed or invalid; but if no document can be found at the specified location, the attribute should be ignored.
A serialization parameter specified in the parameter-document takes precedence over a value supplied directly in the output declaration, except that the values of the cdata-section-elements and suppress-indentation attributes are merged in the same way as when multiple xsl:output declarations are merged.
[ERR XTSE1560] It is a static error if two xsl:output declarations within an output definition specify explicit values for the same attribute (other than cdata-section-elements, suppress-indentation, and use-character-maps), with the values of the attributes being not equal, unless there is another xsl:output declaration within the same output definition that has higher import precedence and that specifies an explicit value for the same attribute.
If the result is not serialized, then the decision whether to return the raw result or to construct a tree depends on the effective value of the build-tree attribute. If the effective value of the build-tree attribute is yes, then a final result tree is created by invoking the process of sequence normalization. Conversely, if the result is serialized, then the decision whether or not to construct a tree depends on the choice of serialization method, and the build-tree attribute is then ignored. For example, with method="xml" a tree is always constructed, whereas with method="json" a tree is never constructed. [XSLT 3.0 Erratum E14, bug 30208].
Note:
The default for build-tree may differ for user-defined serialization methods or for serialization methods introduced in future versions of this specification.
The default value for the indent parameter is now defined to be no for all output methods other than html and xhtml. [Issue 1548 9 November 2024]
If none of the xsl:output declarations within an output definition specifies a value for a particular attribute, then the corresponding serialization parameter takes a default value. The default value depends on the chosen output method.
There are some serialization parameters that apply to some output methods but not to others. For example, the indent attribute has no effect on the text output method. If a value is supplied for an attribute that is inapplicable to the output method, its value is not passed to the serializer. The processor may validate the value of such an attribute, but is not required to do so.
An implementation may allow the attributes of the xsl:output declaration to be overridden, or the default values to be changed, using the API that controls the transformation.
The location to which final result trees are serialized (whether in filestore or elsewhere) is implementation-defined (which in practice may mean that it is controlled using an implementation-defined API). However, these locations must satisfy the constraint that when two final result trees are both created (implicitly or explicitly) using relative URI references in the href attribute of the xsl:result-document instruction, then these relative URI references may be used to construct references from one tree to the other, and such references must remain valid when both result trees are serialized.
The method attribute on the xsl:output element identifies the overall method that is to be used for outputting the final result tree.
[ERR XTSE1570] The value must (if present) be a valid EQName. If it is a lexical QName with no a prefix, then it identifies a method specified in [XSLT and XQuery Serialization] and must be one of xml, html, xhtml, or text. If it is a lexical QName with a prefix, then the lexical QName is expanded into an expanded QName as described in 5.1.1 Qualified Names; the expanded QName identifies the output method; the behavior in this case is not specified by this document.
The default for the method attribute depends on the contents of the tree being serialized, and is chosen as follows. If the document node of the final result tree has an element child, and any text nodes preceding the first element child of the document node of the result tree contain only whitespace characters, then:
If the expanded QName of this first element child has local part html (in lower case), and namespace URI http://www.w3.org/1999/xhtml, then the default output method is normally xhtml. However, if the effective version of the outermost element of the principal stylesheet module in the top-level package has the value 1.0, and if the result tree is generated implicitly (rather than by an explicit xsl:result-document instruction), then the default output method in this situation is xml.
If the expanded QName of this first element child has local part html (in any combination of upper and lower case) and a null namespace URI, then the default output method is html.
In all other cases, the default output method is xml.
The default output method is used if the selected output definition does not include a method attribute.
The other attributes on xsl:output provide parameters for the output method. The following attributes are allowed:
The value of the encoding attribute provides the value of the encoding parameter to the serialization method. The default value is implementation-defined, but in the case of the xml and xhtml methods it must be either UTF-8 or UTF-16.
The byte-order-mark attribute defines whether a byte order mark is written at the start of the file. If the value yes is specified, a byte order mark is written; if no is specified, no byte order mark is written. The default value depends on the encoding used. If the encoding is UTF-16, the default is yes; for UTF-8 it is implementation-defined, and for all other encodings it is no. The value of the byte order mark indicates whether high order bytes are written before or after low order bytes; the actual byte order used is implementation-dependent, unless it is defined by the selected encoding.
The cdata-section-elements attribute is a whitespace-separated list of QNames. The default value is an empty list. After expansion of these names using the applicable static namespaces for the xsl:output declaration in which they appear, this list of names provides the value of the cdata-section-elements parameter to the serialization method. In the case of an unprefixed name, the default namespace (that is, the namespace declared using xmlns="uri") is used.
Note:
This differs from the rule for most other QNames used in a stylesheet. The reason is that these names refer to elements in the result document, and therefore follow the same convention as the name of a literal result element or the name attribute of xsl:element.
The value of the doctype-system attribute provides the value of the doctype-system parameter to the serialization method. If the attribute is absent or has a zero-length string as its value, then the serialization parameter is not set (is “absent”).
The value of the doctype-public attribute provides the value of the doctype-public parameter to the serialization method. If the attribute is absent or has a zero-length string as its value, then the serialization parameter is not set (is “absent”).
The value of doctype-public must conform to the rules for a PubidLiteralXML (see [XML 1.0]).
The value of the escape-solidus attribute provides the value of the escape-solidus parameter to the serialization method. The default value is yes.
The value of the escape-uri-attributes attribute provides the value of the escape-uri-attributes parameter to the serialization method. The default value is yes.
The value of the html-version attribute provides the value of the html-version parameter to the serialization method. The set of permitted values, and the default value, are implementation-defined. A serialization error will be raised if the requested version is not supported by the implementation.
Note:
This serialization parameter is new in version 3.0. If it is absent, the html output method uses the value of the version parameter in its place. For XHTML serialization, the html-version parameter indicates the version of XHTML to be used, while the version parameter indicates the version of XML.
The value of the include-content-type attribute provides the value of the include-content-type parameter to the serialization method. The default value is yes.
The value of the indent attribute provides the value of the indent parameter to the serialization method. The default value is yes in the case of the html and xhtml output methods, no in the case of all other output methods.
The value of the item-separator attribute provides the value of the item-separator parameter to the serialization method. The value of the serialization parameter can be any string (including a zero-length string), or absent. To set the parameter to absent, the item-separator attribute can either be omitted, or set to the special value item-separator="#absent"; it is not possible to set the value of the serialization parameter to the literal 7-character string "#absent".
Note:
The item-separator attribute has no effect if the sequence being serialized contains only one item. [XSLT 3.0 Erratum E14, bug 30208].
The value of the json-lines attribute determines whether the JSON output method should output multiple JSON values in json-lines format (one value per line). The default value is no.
The value of the media-type attribute provides the value of the media-type parameter to the serialization method. The default value is text/xml in the case of the xml output method, text/html in the case of the html and xhtml output methods, and text/plain in the case of the text output method. The default for the json output method is application/json; the default for the adaptive output method is implementation-defined. [XSLT 3.0 Erratum E26, bug 30245].
The value of the normalization-form attribute provides the value of the normalization-form parameter to the serialization method. A value that is an NMTOKEN other than one of those enumerated for the normalization-form attribute specifies an implementation-defined normalization form; the behavior in this case is not specified by this document. The default value is none.
The value of the omit-xml-declaration attribute provides the value of the omit-xml-declaration parameter to the serialization method. The default value is no.
The value of the standalone attribute provides the value of the standalone parameter to the serialization method. The default value is omit; this means that no standalone attribute is to be included in the XML declaration.
The suppress-indentation attribute is a whitespace-separated list of QNames. The default value is an empty list. After expansion of these names using the applicable static namespaces for the xsl:output declaration in which they appear, this list of names provides the value of the suppress-indentation parameter to the serialization method. In the case of an unprefixed name, the default namespace (that is, the namespace declared using xmlns="uri") is used.
Note:
This differs from the rule for most other QNames used in a stylesheet. The reason is that these names refer to elements in the result document, and therefore follow the same convention as the name of a literal result element or the name attribute of xsl:element.
The value of the undeclare-prefixes attribute provides the value of the undeclare-prefixes parameter to the serialization method. The default value is no.
The use-character-maps attribute provides a list of named character maps that are used in conjunction with this output definition. The way this attribute is used is described in 27.326.3 Character Maps. The default value is an empty list.
The value of the version attribute provides the value of the version parameter to the serialization method. The set of permitted values, and the default value, are implementation-defined. A serialization error will be raised if the requested version is not supported by the implementation.
If the processor performs serialization, then it must raise any serialization errors that occur. These have the same effect as dynamic errors: that is, the processor must raise the error and must not finish as if the transformation had been successful.
[Definition: 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.] The effect of character maps is defined in [XSLT and XQuery Serialization].
The character map that is supplied as a parameter to the serializer is determined from the xsl:character-map elements referenced from the xsl:output declaration for the selected output definition.
The xsl:character-map element is a declaration that may appear as a child of the xsl:stylesheet element.
<!-- Category: declaration -->
<xsl:character-map
name = eqname
use-character-maps? = eqnames >
<!-- Content: (xsl:output-character*) -->
</xsl:character-map>
The xsl:character-map declaration declares a character map with a name and a set of character mappings. The character mappings are specified by means of xsl:output-character elements contained either directly within the xsl:character-map element, or in further character maps referenced in the use-character-maps attribute.
The requiredname attribute provides a name for the character map. When a character map is used by an output definition or another character map, the character map with the highest import precedence is used.
The name of a character map is local to the package in which its declaration appears; it may be referenced only from within the same package.
[ERR XTSE1580] It is a static error if a package contains two or more character maps with the same name and the same import precedence, unless it also contains another character map with the same name and higher import precedence.
The optional use-character-maps attribute lists the names of further character maps that are included into this character map.
[ERR XTSE1590] It is a static error if a name in the use-character-maps attribute of the xsl:output or xsl:character-map elements does not match the name attribute of any xsl:character-map in the containing package.
[ERR XTSE1600] It is a static error if a character map references itself, directly or indirectly, via a name in the use-character-maps attribute.
It is not an error if the same character map is referenced more than once, directly or indirectly.
For every xsl:character-map declaration in a package, other than one that is overridden by another of higher import precedence, the static context of the package includes a named character map derived from the xsl:character-map declaration. The name of the named character map is the QName formed by expanding the value of the name attribute, and the content is a map of type map{xs:string, xs:string} that maps characters (represented as xs:string instances of length 1) to their replacement strings.
Recursive expansion of character maps using use-character-maps attributes may produce several mappings for the same character. In this situation, the last character mapping takes precedence. To establish the ordering, the following rules are used:
Within a single xsl:character-map element, the characters defined in character maps referenced in the use-character-maps attribute are considered before the characters defined in the child xsl:output-character elements.
The character maps referenced in a single use-character-maps attribute are considered in the order in which they are listed in that attribute. The expansion is depth-first: each referenced character map is fully expanded before the next one is considered.
Two xsl:output-character elements appearing as children of the same xsl:character-map element are considered in document order.
The xsl:output-character element is defined as follows:
<xsl:output-character
character = char
string = string />
The character map that is passed as a parameter to the serializer contains a mapping for the character specified in the character attribute to the string specified in the string attribute.
Character mapping is not applied to characters for which output escaping has been disabled as described in 27.526.5 Disabling Output Escaping.
If a character is mapped, then it is not subjected to XML or HTML escaping.
Character maps can be useful when producing serialized output in a format that resembles, but is not strictly conformant to, HTML or XML. For example, when the output is a JSP page, there might be a need to generate the output:
<jsp:setProperty name="user" property="id" value='<%= "id" + idValue %>'/>
Although this output is not well-formed XML or HTML, it is valid in Java Server Pages. This can be achieved by allocating three Unicode characters (which are not needed for any other purpose) to represent the strings <%, %>, and ", for example:
<xsl:character-map name="jsp"> <xsl:output-character character="«" string="<%"/> <xsl:output-character character="»" string="%>"/> <xsl:output-character character="§" string='"'/> </xsl:character-map>
When this character map is referenced in the xsl:output declaration, the required output can be produced by writing the following in the stylesheet:
<jsp:setProperty name="user" property="id" value='«= §id§ + idValue »'/>
This works on the assumption that when an apostrophe or quotation mark is generated as part of an attribute value by the use of character maps, the serializer will (where possible) use the other choice of delimiter around the attribute value.
The following example illustrates a composite character map constructed in a modular fashion:
<xsl:output name="htmlDoc" use-character-maps="htmlDoc"/> <xsl:character-map name="htmlDoc" use-character-maps="html-chars doc-entities windows-format"/> <xsl:character-map name="html-chars" use-character-maps="latin1 ..."/> <xsl:character-map name="latin1"> <xsl:output-character character=" " string="&nbsp;"/> <xsl:output-character character="¡" string="&iexcl;"/> ... </xsl:character-map> <xsl:character-map name="doc-entities"> <xsl:output-character character="" string="&t-and-c;"/> <xsl:output-character character="" string="&chap1;"/> <xsl:output-character character="" string="&chap2;"/> ... </xsl:character-map> <xsl:character-map name="windows-format"> <!-- newlines as CRLF --> <xsl:output-character character="
" string="
"/> <!-- tabs as three spaces --> <xsl:output-character character="	" string=" "/> <!-- images for special characters --> <xsl:output-character character="" string="<img src='special1.gif' />"/> <xsl:output-character character="" string="<img src='special2.gif' />"/> ... </xsl:character-map>
Note:
When character maps are used, there is no guarantee that the serialized output will be well-formed XML (or HTML). Furthermore, the fact that the result tree was validated against a schema gives no guarantee that the serialized output will still be valid against the same schema. Conversely, it is possible to use character maps to produce schema-valid output from a result tree that would fail validation.
character-map function The contents of a character map declared using xsl:character-map are now available dynamically via a new character-map function. [Issue 1500 ]
The contents of a character map declared using xsl:character-map are available dynamically via the character-map function.
Delivers the content of a character map declared using xsl:character-map.
fn:character-map( | ||
$name | as xs:QName | |
) as map(xs:string, xs:string)? | ||
This function is deterministicFO, context-dependentFO, and focus-independentFO. It depends on character maps.
The static context for a stylesheet package includes a set of named character maps. This function delivers the content of a character map if a character map with the given name is present in the static context of the containing package, or an empty sequence otherwise.
The returned character map is in a format suitable for use within the $options parameter of the serialize function.
Consider the following character map declaration: | |
<xsl:character-map name="jsp"> <xsl:output-character character="«" string="<%"/> <xsl:output-character character="»" string="%>"/> <xsl:output-character character="§" string='"'/> </xsl:character-map> | |
Then the result of the function call | |
{
"«": "<%",
"»": "%>",
"§": '"'
} | |
This might be used in a call to the function | |
serialize($input, {'method': 'xml',
'use-character-maps': character-map(xs:QName('jsp')) }) |
Normally, when using the XML, HTML, or XHTML output method, the serializer will escape special characters such as & and < when outputting text nodes. This ensures that the output is well-formed. However, it is sometimes convenient to be able to produce output that is almost, but not quite well-formed XML; for example, the output may include ill-formed sections which are intended to be transformed into well-formed XML by a subsequent non-XML-aware process. For this reason, XSLT defines a mechanism for disabling output escaping.
This feature is deprecated.
This is an optional feature: it is not required that an XSLT processor that implements the serialization option should offer the ability to disable output escaping, and there is no conformance level that requires this feature.
This feature requires the serializer (described in [XSLT and XQuery Serialization]) to be extended as follows. Conceptually, the final result tree provides an additional boolean property disable-escaping associated with every character in a text node. When this property is set, the normal action of the serializer to escape special characters such as & and < is suppressed.
An xsl:value-of or xsl:text element may have a disable-output-escaping attribute; the allowed values are yes or no. The default is no; if the value is yes, then every character in the text node generated by evaluating the xsl:value-of or xsl:text element should have the disable-escaping property set.
For example,
<xsl:text disable-output-escaping="yes"><</xsl:text>
should generate the single character <.
If output escaping is disabled for an xsl:value-of or xsl:text instruction evaluated when temporary output state is in effect, the request to disable output escaping is ignored.
Similarly, if an xsl:value-of or xsl:text instruction specifies that output escaping is to be disabled when writing to a final result tree that is not being serialized, the request to disable output escaping is ignored.
Note:
Furthermore, a request to disable output escaping has no effect when the newly constructed text node is used to form the value of an attribute, comment, processing instruction, or namespace node. This is because the rules for constructing such nodes (see 5.8.2 Constructing Simple Content) cause the text node to be atomized, and the process of atomizing a text node takes no account of the disable-escaping property.
If output escaping is disabled for text within an element that would normally be output using a CDATA section, because the element is listed in the cdata-section-elements, then the relevant text will not be included in a CDATA section. In effect, CDATA is treated as an alternative escaping mechanism, which is disabled by the disable-output-escaping option.
For example, if <xsl:output cdata-section-elements="title"/> is specified, then the following instructions:
<title> <xsl:text disable-output-escaping="yes">This is not <hr/> good coding practice</xsl:text> </title>
should generate the output:
<title><![CDATA[This is not ]]><hr/><![CDATA[ good coding practice]]></title>
The disable-output-escaping attribute may be used with the html output method as well as with the xml output method. The text output method ignores the disable-output-escaping attribute, since this method does not perform any output escaping.
A processor will only be able to disable output escaping if it controls how the final result tree is output. This might not always be the case. For example, the result tree might be used as a source tree for another XSLT transformation instead of being output. It is implementation-defined whether (and under what circumstances) disabling output escaping is supported. If disabling output escaping is not supported, any request to disable output escaping is ignored.
If output escaping is disabled for a character that is not representable in the encoding that the processor is using for output, the request to disable output escaping is ignored in respect of that character.
Since disabling output escaping might not work with all implementations and can result in XML that is not well-formed, it should be used only when there is no alternative.
Note:
When disable-output-escaping is used, there is no guarantee that the serialized output will be well-formed XML (or HTML). Furthermore, the fact that the result tree was validated against a schema gives no guarantee that the serialized output will still be valid against the same schema. Conversely, it is possible to use disable-output-escaping to produce schema-valid output from a result tree that would fail validation.
Note:
The facility to define character maps for use during serialization, as described in 27.326.3 Character Maps, has been produced as an alternative mechanism that can be used in many situations where disabling of output escaping was previously necessary, without the same difficulties.
Changes in 4.0 ⬆
A processor that claims conformance with this specification must satisfy the conformance requirements for a basic XSLT processor and for each of the optional features with which it claims conformance.
The following optional features are defined:
The schema-awareness feature, defined in 28.227.2 Schema-Awareness Conformance Feature
The serialization feature, defined in 28.327.3 Serialization Feature
The backwards compatibility feature, defined in 28.427.4 Compatibility Features
The streaming feature, defined in 28.527.5 Streaming Feature.
The dynamic evaluation feature, defined in 28.627.6 Dynamic Evaluation Feature.
A processor that does not claim conformance with an optional feature must satisfy the requirements for processors that do not implement that feature.
Note:
There is no conformance level or feature defined in this specification that requires implementation of the static typing features described in [XPath 3.0]. An XSLT processor may provide a user option to invoke static typing, but to be conformant with this specification it must allow a stylesheet to be processed with static typing disabled. The interaction of XSLT stylesheets with the static typing feature of XPath 3.0 has not been specified, so the results of using static typing, if available, are implementation-defined.
An XSLT processor takes as its inputs a stylesheet and zero or more XDM trees conforming to the data model defined in [XDM 3.0]. It is not required that the processor supports any particular method of constructing XDM trees, but conformance can only be tested if it provides a mechanism that enables XDM trees representing the stylesheet and primary source document to be constructed and supplied as input to the processor.
The output of the XSLT processor consists of zero or more final result trees. It is not required that the processor supports any particular method of accessing a final result tree, but if it does not support the serialization feature, conformance can only be tested if it provides some alternative mechanism that enables access to the results of the transformation.
Certain facilities in this specification are described as producing implementation-defined results. A claim that asserts conformance with this specification must be accompanied by documentation stating the effect of each implementation-defined feature. For convenience, a non-normative checklist of implementation-defined features is provided at GF Checklist of Implementation-Defined Features.
A conforming processormust raise any static error occurring in the stylesheet, or in any XPath expression, except where specified otherwise either for individual error conditions or under the general provisions for forwards compatible behavior (see 3.10 Forwards Compatible Processing). After raising such an error, the processor may continue for the purpose of raising additional errors, but must terminate abnormally without performing any transformation.
When a dynamic error occurs during the course of a transformation, and is not caught using xsl:catch, the processor must raise it and must eventually terminate abnormally.
Some errors, notably type errors, may be treated as static errors or dynamic errors at the discretion of the processor.
A conforming processor may impose limits on the processing resources consumed by the processing of a stylesheet.
The mandatory requirements of this specification are taken to include the mandatory requirements of [XPath 3.0], [XDM 3.0], and [Functions and Operators 4.0]. An XSLT 3.0 processor must provide a mode of operation which conforms to the 3.0 versions of those specifications as extended by 21 Maps and 23 Processing JSON Data.
A processor may also provide a mode of operation which conforms to versions of those specifications later than the 3.1 versions; in such cases the detail of how XSLT 3.0 interacts with new features introduced by such later versions (for example, extensions to the data model) is implementation-defined.
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.
Some of the optional features are defined in such a way that if the feature is not provided, the data model is constrained to exclude certain kinds of item. For example:
A processor that does not provide the schema-awareness feature restricts the data model so that it does not contain atomic items of types other than the built-in types, or nodes with non-trivial type annotations.
[ERR XTDE1665] A dynamic errormay be raised if the input to the processor includes an item that requires availability of an optional feature that the processor does not provide.
Note:
It is not necessarily possible to trigger this error. A processor that does not provide an optional feature might not define or recognize any representation of the items that are disallowed. The error code is provided for use in cases where a processor is able to interoperate with other software that does not have the same constraints — for example, where a package compiled with a non-schema-aware processor is able to invoke functions in a package that was compiled with a schema-aware processor. Even in that case, processors have the option of filtering or converting the input so that it meets the relevant constraints: for example, a non-schema-aware processor when presented with a schema-validated document in the form of a PSVI might simply ignore the properties it does not understand.
The dynamic error is optional: for example a processor might report no error if the offending item is not actually used.
The phrase input to the processor is deliberately wide: it includes (inter alia) the global context item, items present in the initial match selection, items passed as stylesheet parameters, items returned by functions such as document, doc, and collection, items returned by extension functions and extension instructions, items supplied in function or template parameters or results across package boundaries, and nodes reachable from any of the above by axis navigation.
[Definition: A basic XSLT processor is an XSLT processor that implements all the mandatory requirements of this specification with the exception of constructs explicitly associated with an optional feature.] These constructs are listed below.
A conformant processor must either be a conformant schema-aware XSLT processor or a conformant non-schema-aware processor.
[Definition: A schema-aware XSLT processor is an XSLT processor that implements the mandatory requirements of this specification connected with the xsl:import-schema declaration, the [xsl:]validation and [xsl:]type attributes, and the ability to handle input documents whose nodes have type annotations other than xs:untyped and xs:untypedAtomic. The mandatory requirements of this specification are taken to include the mandatory requirements of XPath 3.0, as described in [XPath 3.0]. 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.]
[Definition: A non-schema-aware processor is a processor that does not claim conformance with the schema-aware conformance feature. Such a processor must handle constructs associated with schema-aware processing as described in this section.]
[ERR XTSE1650] A non-schema-aware processormust raise a static error if a package includes an xsl:import-schema declaration.
Note:
A processor that rejects an xsl:import-schema declaration will also reject any reference to a user-defined type defined in a schema, or to a user-defined element or attribute declaration; it will not, however, reject references to the built-in types listed in 3.14 Built-in Types.
A non-schema-aware processor is not able to validate input documents, and is not able to handle input documents containing type annotations other than xs:untyped or xs:untypedAtomic. Therefore, such a processor must treat any [xsl:]validation attribute with a value of preserve or lax, or a [xsl:]default-validation attribute with a value of preserve as if the value were strip.
Note:
The values lax and preserve indicate that the validation to be applied depends on the calling application, so it is appropriate for the request to be treated differently by different kinds of processor. By contrast, requesting strict validation, either through the [xsl:]validation attribute or the type attribute, indicates that the stylesheet is expecting to deal with typed data, and therefore cannot be processed without performing the validation.
[ERR XTSE1660] A non-schema-aware processormust raise a static error if a package includes an [xsl:]type attribute; or an [xsl:]validation or [xsl:]default-validation attribute with a value other than strip, preserve, or lax; or an xsl:mode element whose typed attribute is equal to yes or strict; or an as attribute whose value is a SequenceType that can only match nodes with a type annotation other than xs:untyped or xs:untypedAtomic (for example, as="element(*, xs:integer)").
A non-schema-aware processor constrains the data model as follows, and raises a dynamic error ([see ERR XTDE1665]) if the constraints are not satisfied:
Atomic items must belong to one of the atomic types listed in 3.14 Built-in Types (except as noted below).
An atomic item may also belong to an implementation-defined type that has been added to the context for use with extension functions or extension instructions.
The set of constructor functions available are limited to those that construct values of the above atomic types.
The static context, which defines the full set of type names recognized by an XSLT processor and also by the XPath processor, includes these atomic types, plus xs:anyType, xs:anySimpleType, xs:untyped, and xs:anyAtomicType.
Element nodes must be annotated with the type annotationxs:untyped, and attribute nodes with the type annotation xs:untypedAtomic.
[Definition: 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 2726 Serialization.] It must respect all the attributes of the xsl:output and xsl:character-map declarations, and must provide all four output methods, xml, xhtml, html, and text. Where the specification uses words such as must and required, then it must serialize the result tree in precisely the way described; in other cases it may use an alternative, equivalent representation.
A processor may claim conformance with the serialization feature whether or not it supports the setting disable-output-escaping="yes" on xsl:text, or xsl:value-of.
A processor that does not claim conformance with the serialization feature must not raise an error merely because the stylesheet contains xsl:output or xsl:character-map declarations, or serialization attributes on the xsl:result-document instruction. Such a processor may check that these declarations and attributes have valid values, but is not required to do so. Apart from optional validation, these declarations should be ignored.
Note:
A processor that does not claim conformance with the serialization feature may offer alternative serialization capabilities, and these may make use of the serialization parameters defined on xsl:output and/or xsl:result-document. Such a processor may implement selected parts of the serialization capabilities defined in this specification. For example, it may implement selected output methods, or selected serialization properties. It may implement sequence normalization using the item-separator property even if it has no other serialization capabilities. [XSLT 3.0 Erratum E14, bug 30208].
If the processor claims conformance with the serialization feature then it must fully implement the serialize function defined in [Functions and Operators 4.0], and must not raise error [ERR FODC0010] FO40 as the result of such a call.
If the processor does not claim conformance with the serialization feature, then it may raise error [ERR FODC0010] FO40 in respect of some or all calls on the serialize function; it must not return a result from a call on this function unless the result is conformant with the specification, given the parameters actually supplied.
A processor that claims conformance with the Serialization Feature must satisfy the mandatory requirements of [XSLT and XQuery Serialization]. It must provide a mode of operation which conforms to the 3.0 version of that specification. It may also provide a mode of operation which conforms to a later version of that specification; in such cases the detail of how XSLT 3.0 interacts with new features introduced by such a version (for example, support for new serialization properties) is implementation-defined.
[Definition: A processor that claims conformance with the XSLT 1.0 compatibility featuremust support the processing of stylesheet instructions and XPath expressions with XSLT 1.0 behavior, as defined in 3.9 Backwards Compatible Processing.]
Note that a processor that does not claim conformance with the XSLT 1.0 compatibility featuremust raise a dynamic error if an instruction is evaluated whose effective version is 1.0. [see ERR XTDE0160].
Note:
The reason this is a dynamic error rather than a static error is to allow stylesheets to contain conditional logic, following different paths depending on whether the XSLT processor implements XSLT 1.0, 2.0, or 3.0. The selection of which path to use can be controlled by using the system-property function to test the xsl:version system property.
A processor that claims conformance with the XSLT 1.0 compatibility featuremust permit the use of the namespace axis in XPath expressions when backwards compatible behavior is enabled. In all other circumstances, support for the namespace axis is optional.
Note:
There are no incompatibilities between 3.0 and 2.0 that would justify a 2.0-compatibility mode. When a 3.0 processor encounters a stylesheet that specifies version="2.0", evaluation therefore proceeds exactly as if it specified version="3.0". However, a software product may invoke an XSLT 2.0 processor in preference to an XSLT 3.0 processor when the stylesheet specifies version="2.0", in which case any use of new 3.0 constructs will be rejected.
[Definition: A processor that claims conformance with the streaming featuremust use streamed processing in cases where (a) streaming is requested (for example by using the attribute streamable="yes" on xsl:mode, or on the xsl:source-document instruction) and (b) the constructs in question are guaranteed-streamable according to this specification.]
A processor that does not claim conformance with the streaming feature is not required to use streamed processing and is not required to determine whether any construct is guaranteed streamable. Such a processor must, however, implement the semantics of all constructs in the language provided that enough memory is available to perform the processing without streaming.
A processor that conforms with the feature must return the value "yes" in response to the function call system-property('xsl:supports-streaming'); a processor that does not conform with the feature must return the value "no".
Note:
The term streamed processing as used here means the ability to process arbitrarily large input documents without ever-increasing memory requirements.
[Definition: A processor that claims conformance with the dynamic evaluation featuremust evaluate the xsl:evaluate function as described in this specification.]
A processor that does not claim conformance with the dynamic evaluation feature must raise a dynamic error if an xsl:evaluate instruction is evaluated. It must not raise a static error merely because of the presence of an xsl:evaluate instruction in the stylesheet, unless a processor that conforms with the feature would raise the same static error.
A processor that conforms with the feature must return the value "yes" in response to the function call system-property('xsl:supports-dynamic-evaluation'); a processor that does not conform with the feature must return the value "no".
A processor that conforms with the feature must return the value true in response to the function call element-available('xsl:evaluate'); a processor that does not conform with the feature must return the value false.
Note:
A processor may allow dynamic evaluation to be enabled and disabled by means of configuration settings, perhaps for security reasons. In consequence, it may be impossible to tell during static analysis of the stylesheet whether or not the feature will be available during execution. A stylesheet author wanting to check whether the feature is available should therefore make the test using a run-time call on system-property, rather than relying on tests in an [xsl:]use-when attribute.
This appendix contains a stylesheet that can be used for converting the XML representation of JSON described in Section 14.3.2 XML Representation of JSONFO into strings matching the JSON grammar.
This stylesheet is also available as a separate resource (links are listed at the top of this document).
The schema for this XML representation of JSON is described at Section 14.3.2 XML Representation of JSONFO.
The stylesheet contains the implementation of a function very similar to xml-to-json, but implemented in XSLT so that it can be customized and extended. This stylesheet is provided for the benefit of users and there are no conformance requirements associated with it; there is no requirement that processors should make this stylesheet available. The stylesheet is reproduced below:
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This is a stylesheet for converting XML to JSON.
* It expects the XML to be in the format produced by the XSLT 3.0 function
* fn:json-to-xml(), but is designed to be highly customizable.
*
* The stylesheet is made available under the terms of the W3C software notice and license
* at http://www.w3.org/Consortium/Legal/copyright-software-19980720
*
-->
<xsl:package
name="http://www.w3.org/2013/XSLT/xml-to-json"
package-version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:j="http://www.w3.org/2013/XSLT/xml-to-json"
exclude-result-prefixes="xs fn j" default-mode="j:xml-to-json" version="3.0">
<xsl:variable name="quot" visibility="private">"</xsl:variable>
<xsl:param name="indent-spaces" select="2"/>
<!-- The static parameter STREAMABLE controls whether the stylesheet is declared as streamable -->
<xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
<xsl:mode name="j:xml-to-json"/> <!-- fixes erratum E30 for bug 30288 -->
<xsl:mode name="indent" _streamable="{$STREAMABLE}" visibility="public"/>
<xsl:mode name="no-indent" _streamable="{$STREAMABLE}" visibility="public"/>
<xsl:mode name="key-attribute" streamable="false" on-no-match="fail" visibility="public"/>
<!-- The static parameter VALIDATE controls whether the input, if untyped, should be validated -->
<xsl:param name="VALIDATE" static="yes" as="xs:boolean" select="false()"/>
<xsl:import-schema namespace="http://www.w3.org/2005/xpath-functions" use-when="$VALIDATE"/>
<!-- Entry point: function to convert a supplied XML node to a JSON string -->
<xsl:function name="j:xml-to-json" as="xs:string" visibility="public">
<xsl:param name="input" as="node()"/>
<xsl:sequence select="j:xml-to-json($input, map { })"/>
</xsl:function>
<!-- Entry point: function to convert a supplied XML node to a JSON string, supplying options -->
<xsl:function name="j:xml-to-json" as="xs:string" visibility="public">
<xsl:param name="input" as="node()"/>
<xsl:param name="options" as="map(*)"/>
<xsl:variable name="input" as="node()" use-when="$VALIDATE">
<xsl:copy-of select="$input" validation="strict"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$options('indent') eq true()">
<xsl:apply-templates select="$input" mode="indent">
<xsl:with-param name="fallback" as="(function(element()) as xs:string)?"
select="$options('fallback')" tunnel="yes"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$input" mode="no-indent">
<xsl:with-param name="fallback" as="(function(element()) as xs:string)?"
select="$options('fallback')" tunnel="yes"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<!-- A document node is ignored -->
<xsl:template match="/" mode="indent no-indent">
<xsl:apply-templates mode="#current"/>
</xsl:template>
<!-- Template rule for fn:map elements, representing JSON objects -->
<xsl:template match="fn:map" mode="indent">
<xsl:value-of>
<xsl:variable name="depth" select="count(ancestor::*) + 1"/>
<xsl:text>{</xsl:text>
<xsl:for-each select="*">
<xsl:if test="position() gt 1">
<xsl:text>, </xsl:text>
<xsl:value-of select="j:indent($depth)"/>
</xsl:if>
<xsl:apply-templates select="snapshot(@key)" mode="key-attribute"/>
<xsl:text> : </xsl:text>
<xsl:apply-templates select="." mode="#current"/>
</xsl:for-each>
<xsl:text>}</xsl:text>
</xsl:value-of>
</xsl:template>
<xsl:template match="fn:map" mode="no-indent">
<xsl:value-of>
<xsl:text>{</xsl:text>
<xsl:for-each select="*">
<xsl:if test="position() gt 1">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:apply-templates select="snapshot(@key)" mode="key-attribute"/>
<xsl:text>:</xsl:text>
<xsl:apply-templates select="." mode="#current"/>
</xsl:for-each>
<xsl:text>}</xsl:text>
</xsl:value-of>
</xsl:template>
<!-- Template rule for fn:array elements, representing JSON arrays -->
<xsl:template match="fn:array" mode="indent">
<xsl:value-of>
<xsl:variable name="depth" select="count(ancestor::*) + 1"/>
<xsl:text>[</xsl:text>
<xsl:for-each select="*">
<xsl:if test="position() gt 1">
<xsl:text>, </xsl:text>
<xsl:value-of select="j:indent($depth)"/>
</xsl:if>
<xsl:apply-templates select="." mode="#current"/>
</xsl:for-each>
<xsl:text>]</xsl:text>
</xsl:value-of>
</xsl:template>
<xsl:template match="fn:array" mode="no-indent">
<xsl:value-of>
<xsl:text>[</xsl:text>
<xsl:for-each select="*">
<xsl:if test="position() gt 1">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="#current"/>
</xsl:for-each>
<xsl:text>]</xsl:text>
</xsl:value-of>
</xsl:template>
<!-- Template rule for fn:string elements in which
special characters are already escaped -->
<xsl:template match="fn:string[@escaped='true']" mode="indent no-indent">
<xsl:sequence select="concat($quot, ., $quot)"/>
</xsl:template>
<!-- Template rule for fn:string elements in which
special characters need to be escaped -->
<xsl:template match="fn:string[not(@escaped='true')]" mode="indent no-indent">
<xsl:sequence select="concat($quot, j:escape(.), $quot)"/>
</xsl:template>
<!-- Template rule for fn:boolean elements -->
<xsl:template match="fn:boolean" mode="indent no-indent">
<xsl:sequence select="xs:string(xs:boolean(.))"/>
</xsl:template>
<!-- Template rule for fn:number elements -->
<xsl:template match="fn:number" mode="indent no-indent">
<xsl:value-of select="xs:string(xs:double(.))"/>
</xsl:template>
<!-- Template rule for JSON null elements -->
<xsl:template match="fn:null" mode="indent no-indent">
<xsl:text>null</xsl:text>
</xsl:template>
<!-- Template rule matching a key within a map where
special characters in the key are already escaped -->
<xsl:template match="fn:*[@key-escaped='true']/@key" mode="key-attribute">
<xsl:value-of select="concat($quot, ., $quot)"/>
</xsl:template>
<!-- Template rule matching a key within a map where
special characters in the key need to be escaped -->
<xsl:template match="fn:*[not(@key-escaped='true')]/@key" mode="key-attribute">
<xsl:value-of select="concat($quot, j:escape(.), $quot)"/>
</xsl:template>
<!-- Template matching "invalid" elements -->
<xsl:template match="*" mode="indent no-indent">
<xsl:param name="fallback" as="(function(element()) as xs:string)?"
tunnel="yes" required="yes"/>
<xsl:choose>
<xsl:when test="exists($fallback)">
<xsl:value-of select="$fallback(snapshot(.))"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">>Inc</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Template rule matching (and discarding) whitespace text nodes in the XML -->
<xsl:template match="text()[not(normalize-space())]" mode="indent no-indent"/>
<!-- Function to escape special characters -->
<xsl:function name="j:escape" as="xs:string" visibility="final">
<xsl:param name="in" as="xs:string"/>
<xsl:value-of>
<xsl:for-each select="string-to-codepoints($in)">
<xsl:choose>
<xsl:when test=". gt 65535">
<xsl:value-of select="concat('\u', j:hex4((. - 65536) idiv 1024 + 55296))"/>
<xsl:value-of select="concat('\u', j:hex4((. - 65536) mod 1024 + 56320))"/>
</xsl:when>
<xsl:when test=". = 34">\"</xsl:when>
<xsl:when test=". = 92">\\</xsl:when>
<xsl:when test=". = 08">\b</xsl:when>
<xsl:when test=". = 09">\t</xsl:when>
<xsl:when test=". = 10">\n</xsl:when>
<xsl:when test=". = 12">\f</xsl:when>
<xsl:when test=". = 13">\r</xsl:when>
<xsl:when test=". lt 32 or (. ge 127 and . le 160)">
<xsl:value-of select="concat('\u', j:hex4(.))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="codepoints-to-string(.)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:value-of>
</xsl:function>
<!-- Function to convert a UTF16 codepoint into a string of four hex digits -->
<xsl:function name="j:hex4" as="xs:string" visibility="final">
<xsl:param name="ch" as="xs:integer"/>
<xsl:variable name="hex" select="'0123456789abcdef'"/>
<xsl:value-of>
<xsl:value-of select="substring($hex, $ch idiv 4096 + 1, 1)"/>
<xsl:value-of select="substring($hex, $ch idiv 256 mod 16 + 1, 1)"/>
<xsl:value-of select="substring($hex, $ch idiv 16 mod 16 + 1, 1)"/>
<xsl:value-of select="substring($hex, $ch mod 16 + 1, 1)"/>
</xsl:value-of>
</xsl:function>
<!-- Function to output whitespace indentation based on
the depth of the node supplied as a parameter -->
<xsl:function name="j:indent" as="text()" visibility="public">
<xsl:param name="depth" as="xs:integer"/>
<xsl:value-of select="'
', string-join((1 to ($depth + 1) * $indent-spaces) ! ' ', '')"/>
</xsl:function>
</xsl:package>
A component of the context that has no value is said to be absent.
An operand usage of absorption indicates that the construct reads the subtree(s) rooted at a supplied node(s).
An accumulator defines a series of values associated with the nodes of the tree. If an accumulator is applicable to a particular tree, then for each node in the tree, other than attribute and namespace nodes, there will be two values available, called the pre-descent and post-descent values. These two values are available via a pair of functions, accumulator-before and accumulator-after.
The functions accumulator-before and accumulator-after are referred to as the accumulator functions.
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.
A template rule is applicable to one or more modes. The modes to which it is applicable are defined by the mode attribute of the xsl:template element. If the attribute is omitted, then the template rule is applicable to the default mode specified in the [xsl:]default-mode attribute of the innermost containing element that has such an attribute, which in turn defaults to the unnamed mode. If the mode attribute is present, then its value must be a non-empty whitespace-separated list of tokens, each of which defines a mode to which the template rule is applicable.
The applicable static namespaces for an element in a stylesheet module are the fixed namespace bindings for the module if the root element of the module has a fixed-namespaces attribute, or the native namespace bindings of the element otherwise.
A function definition has an arity range, which defines the minimum and maximum number of arguments that must be supplied in a call to the function. The static context can contain multiple function definitions with the same name, provided that their arity ranges do not overlap.
The term atomization is defined in Section 2.5.3 AtomizationXP. It is a process that takes as input a sequence of items, and returns a sequence of atomic items, in which the nodes are replaced by their typed values as defined in [XDM 3.0]. Arrays (see 22 Arrays) are atomized by atomizing their members, recursively.
An attribute set is defined as a set of xsl:attribute-set declarations in the same package that share the same expanded QName.
An attribute set invocation is a pseudo-instruction corresponding to a single EQName appearing within an [xsl:]use-attribute-sets attribute; the effect of the pseudo-instruction is to cause the referenced attribute set to be evaluated.
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 ({}), following the general rules for value templates
An element is processed with backwards compatible behavior if its effective version is less than 4.0.
The base output URI is a URI to be used as the base URI when resolving a relative URI reference 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.
A basic XSLT processor is an XSLT processor that implements all the mandatory requirements of this specification with the exception of constructs explicitly associated with an optional feature.
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.
For some construct kinds, one or more operand roles may be defined to form a choice operand group. This concept is used where it is known that operands are mutually exclusive (for example the then and else clauses in a conditional expression).
A circularity is said to exist if a construct such as a global variable, an attribute set, or a key, cannot be evaluated without reference to its own value. 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.
Climbing: indicates that streamed nodes returned by the construct are reached by navigating the parent, ancestor[-or-self], attribute, and/or namespace axes from the node at the current streaming position.
When used in this specification without further qualification, the term coercion rules means the coercion rules defined in [XPath 4.0], applied with XPath 1.0 compatibility mode set to false.
Facilities in XSLT 3.0 and XPath 3.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.
The ordered collection of merge key values computed for one item in a merge input sequence (one for each merge key component within the merge key specification) is referred to as a combined merge key value.
The combined posture of a choice operand group is determined by the postures of the operands in the group (the operand postures), and is the first of the following that applies:
If any of the operand postures is roaming, then the combined posture is roaming.
If all of the operand postures are grounded, then the combined posture is grounded.
If one or more of the operand postures is climbing and the remainder (if any) are grounded, then the combined posture is climbing.
If one or more of the operand postures is striding and the remainder (if any) are grounded, then the combined posture is striding.
If one or more of the operand postures is crawling and each of the remainder (if any) is either striding or grounded, then the combined posture is crawling.
Otherwise (for example, if the group includes both an operand with climbing posture and one with crawling posture), the combined posture is roaming.
The signatures of two components are compatible if they present the same interface to the user of the component. The additional rules depend on the kind of component.
The term component is used to refer to any of the following: a stylesheet function, a named template, a mode, an accumulator, an attribute set, a key, global variable, or a mode.
The term construct refers to the union of the following: a sequence constructor, an instruction, an attribute set, a value template, an expression, or a pattern.
A consuming construct is any construct deemed consuming by the rules in this section (19 Streamability).
A component declaration results in multiple components, one in the package in which the declaration appears, and potentially one in each package that uses the declaring package, directly or indirectly, subject to the visibility of the component. Each of these multiple components has the same declaring package, but each has a different containing package. For the original component, the declaring package and the containing package are the same; for a copy of a component made as a result of an xsl:use-package declaration, the declaring package will be the original package, and the containing package will be the package in which the xsl:use-package declaration appears.
The context item is the item currently being processed. An item (see [XDM 3.0]) is either an atomic item (such as an integer, date, or string), a node, or a function item. 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.
For every expression, it is possible to establish by static analysis, information about the item type of the context item for evaluation of that expression. This is called the context item type of the expression.
If the context item is a node (as distinct from an atomic item 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 item or a function item, there is no context node.
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.
The context posture. This captures information about how the context item used as input to the construct is positioned relative to the streamed input. The context posture of a construct C is the posture of the expression whose value sets the focus for the evaluation of C.
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).
Within a focus-changing construct there are one or more operands that are evaluated with a focus determined by the controlling operand (or in some cases such as xsl:on-completion, with an absentfocus); these are referred to as controlled operands.
Within a focus-changing construct there is in many cases one operand whose value determines the focus for evaluating other operands; this is referred to as the controlling operand.
Crawling: typically indicates that streamed nodes returned by a construct are reached by navigating the descendant[-or-self] axis.
While the xsl:matching-substring instruction is active, a set of current captured substrings is available, corresponding to the parenthesized subexpressions of the regular expression.
The current group is the group itself, as a sequence of items
The current grouping key is a single atomic item, or in the case of a composite key, a sequence of atomic items, containing the grouping key of the items in the current group.
The current merge group is a map. During evaluation of an xsl:merge instruction, as each group of items with equal combined merge key values is processed, the current merge group is set to a map whose keys are the names of the various merge sources, and whose associated values are the items from each merge source having the relevant composite merge key value.
The current merge key is a an array, whose members are sequences of atomic items. There is one member in the array for each xsl:merge-key element in the merge key specification. During evaluation of an xsl:merge instruction, as each group of items with equal combined merge key values is processed, the current merge key is set to the combined merge key value that these items have in common.
At any point in the processing of a stylesheet, there is a current mode. When the transformation is initiated, the current mode is the initial mode, as described in 2.3 Initiating a Transformation. Whenever an xsl:apply-templates instruction is evaluated, the current mode becomes the mode selected by this instruction.
The current output URI is the URI associated with the principal result or secondary result that is currently being written.
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.
All the xsl:decimal-format declarations in a package 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.
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 3.7.4 User-defined Data Elements)
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.
The above constructs (template rules belonging to a mode declared with streamable="yes"; and xsl:source-document, xsl:attribute-set, xsl:function, xsl:merge-source, and xsl:accumulator elements specifying streamable="yes") are said to be declared-streamable.
The declaring package of a component is the package that contains the declaration (or, in the case of xsl:attribute-set and xsl:key, multiple declarations) of the component.
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.
If no priority attribute is specified on an xsl:template element, a default priority is computed, based on the syntax of the pattern supplied in the match attribute.
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 an attribute or text node within a stylesheet module, or as the result of evaluating an XPath expression contained in such a node. The element containing this attribute or text node is referred to as the defining element of the lexical QName.
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.
An error that is not capable of detection until a source document is being transformed is referred to as a dynamic error.
A processor that claims conformance with the dynamic evaluation featuremust evaluate the xsl:evaluate function as described in this specification.
An xsl:function declaration F is said to be eclipsed if the containing package includes an xsl:function declaration G such that F and G have the same name, F has lower import precedence than G, and the arity range of G includes the totality of the arity range of F.
The effective value of an attribute or text node in the stylesheet is the value after any required expansion or normalization.
The effective version of an element in a stylesheet module or package manifest is the decimal value of the [xsl:]version attribute (see 3.4 Standard Attributes) on that element or on the innermost ancestor element that has such an attribute, subject to special rules for the xsl:output and xsl:fallback elements.
A stylesheet module whose outermost element is the child of a non-XSLT element in a host document is referred to as an embedded stylesheet module. See 3.12 Embedded Stylesheet Modules.
A mode declared by an xsl:mode declaration that has one or more contained xsl:template declarations is referred to as an enclosing mode.
An EQName is a string representing an expanded QName where the string, after removing leading and trailing whitespace, is in the form defined by the EQNameXP production in the XPath specification.
An expanded QName is a value in the value space of the xs:QName datatype as defined in the XDM data model (see [XDM 3.0]): that is, a triple containing namespace prefix (optional), namespace URI (optional), and local name. 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.
An explicit default for a parameter is indicated by the presence of either a select attribute or a non-empty sequence constructor.
A parameter is explicitly mandatory if it is a function parameterwith no required attribute, or if the required attribute is present and has the value yes.
Within this specification, the term XPath expression, or simply expression, means a string that matches the production ExprXP defined in [XPath 3.0].
An element from the XSLT namespace may have any attribute not from the XSLT namespace, provided that the expanded QName (see [XPath 3.0]) of the attribute has a non-null namespace URI. These attributes are referred to as extension attributes.
An extension function is a named function introduced to the static or dynamic context by mechanisms outside the scope of this specification.
An extension instruction is an element within a sequence constructor that is in a namespace (not the XSLT namespace) designated as an extension namespace.
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.
The first of the two output states is called final output state. This state applies when instructions are writing to a final result tree.
A final result tree is a result tree that forms part of the output of a transformation: specifically, a tree built by post-processing the items in the principal result or in a secondary result. Once created, the contents of a final result tree are not accessible within the stylesheet itself.
The fixed namespace bindings for a stylesheet module are established using the fixed-namespaces attribute on the xsl:stylesheet, xsl:transform, or xsl:package element enclosing the stylesheet module.
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.
A focus-changing construct is a construct that has one or more operands that are evaluated with a different focus from the parent construct.
The focus-setting container of a construct C is the innermost focus-changing constructF (if one exists) such that C is directly or indirectly contained in a controlled operand of F. If there is no such construct F, then the focus-setting container is the containing declaration, for example an xsl:function or xsl:template element.
An element is processed with forwards compatible behavior if its effective version is greater than 4.0.
A free-ranging construct is any construct deemed free-ranging by the rules in this section (19 Streamability).
The term function definition is defined in Section 2.2.1 Static ContextXP. It is the definition of a function that can be called statically from within an XPath expression: in the case of XSLT it typically means either a stylesheet function, or a built-in function such as those defined in [Functions and Operators 4.0]
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.
There are 28 fundamental item types: the 7 node kinds defined in [XDM 3.0] (element, attribute, etc.), the 19 primitive atomic types defined in [XML Schema Part 2], plus the types fn(*) and xs:untypedAtomic. The fundamental item types are disjoint, and every item is an instance of exactly one of them.
Many constructs share the same streamability rules. These rules, referred to as the general streamability rules, are defined here.
An item that is the global context item for the transformation acts as the context item when evaluating the select expression or sequence constructor of a global variablewhose declaration is within the top-level package, as described in 5.3.3.1 Maintaining Position: the Focus. The global context item may also be available in a named template when the stylesheet is invoked as described in 2.3.4 Call-Template Invocation
A top-levelvariable-binding element declares a global variable that is visible everywhere except within any region where it is shadowed by another variable binding.
Grounded: indicates that the value returned by the construct does not contain nodes from the streamed input document
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 item in a group must match.
If either of the group-by or group-adjacent attributes is present, then for each item in the population a set of grouping keys is calculated, as follows: the expression contained in the group-by or group-adjacent attribute is evaluated; the result is atomized; and any xs:untypedAtomic items are cast to xs:string. If composite="yes" is specified, there is a single grouping key whose value is the resulting sequence; otherwise, there is a set of grouping keys, consisting of the distinct atomic items present in the result sequence.
A guaranteed-streamable construct is a construct that is declared to be streamable and that follows the particular rules for that construct to make streaming possible, as defined by the analysis in this specification.
Whether or not the operand is higher-order. For this purpose an operand O of a construct C is higher-order if the semantics of C potentially require O to be evaluated more than once during a single evaluation of C.
Two components are said to be homonymous if they have the same symbolic identifier.
Types S and T are considered identical for the purpose of these rules if and only if subtype(S, T) and subtype(T, S) both hold, where the subtype relation is defined in Section 3.3.1 Subtypes of Sequence TypesXP.
The result of evaluating a sequence constructor is the sequence of items formed by concatenating the results of evaluating each of the nodes in the sequence constructor, retaining order. This is referred to as the immediate result of the sequence constructor.
A specific product that performs the functions of an XSLT processor is referred to as an implementation.
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.
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.
If a parameter that is not explicitly mandatory has no explicit default value, then it has an implicit default value, which is the empty sequence if there is an as attribute, or a zero-length string if not.
If a parameter has an implicit default value which cannot be converted to the required type (that is, if it has an as attribute which does not permit the empty sequence), then the parameter is implicitly mandatory.
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.
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.
A stylesheet may be evaluated by calling a named stylesheet function, referred to as the initial function.
For each group, the item within the group that is first in population order is known as the initial item of the group.
A stylesheet may be evaluated by supplying a value to be processed, together with an initial mode. The value (which can be any sequence of items) is referred to as the initial match selection. The processing then corresponds to the effect of the xsl:apply-templates instruction.
The initial mode is the mode used to select template rules for processing items in the initial match selection when apply-templates invocation is used to initiate a transformation.
A stylesheet may be evaluated by selecting a named template to be evaluated; this is referred to as the initial named template.
The sequence to be sorted is referred to as the initial sequence.
The initial setting of a component of the dynamic context is used when evaluating global variables and stylesheet parameters, when evaluating the use and match attributes of xsl:key, and when evaluating the initial-value of xsl:accumulator and the select expressions or contained sequence constructors of xsl:accumulator-rule
The schema components that may be referenced by name in a package are referred to as the in-scope schema components.
An operand usage of inspection indicates that the construct accesses properties of a supplied node that are available without reading its subtree.
An instruction is either an XSLT instruction or an extension instruction.
The following constructs are classified as invocation constructs: the instructions xsl:call-template, xsl:apply-templates, xsl:apply-imports, and xsl:next-match; XPath function calls that bind to stylesheet functions; XPath dynamic function calls; the functions accumulator-before and accumulator-after; the [xsl:]use-attribute-sets attribute. These all have the characteristic that they can cause evaluation of constructs that are not lexically contained within the calling construct.
A key is defined as a set of xsl:key declarations in the same package that share the same name.
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.
A lexical QName is a string representing an expanded QName where the string, after removing leading and trailing whitespace, is within the lexical space of the xs:QName datatype as defined in XML Schema (see [XML Schema Part 2]): that is, a local name optionally preceded by a namespace prefix and a colon.
Every package within a stylesheet, other than the top-level package, is referred to as a library package.
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.
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 25.224.2 Extension Instructions) is classified as a literal result element.
As well as being allowed as a declaration, the xsl:variable element is also allowed in sequence constructors. Such a variable is known as a local variable.
The match type of a pattern is the most specific U-type that is known to match all items that the pattern can match.
A merge activation is a single evaluation of the sequence constructor contained within the xsl:merge-action element, which occurs once for each distinct combined merge key value.
A merge input sequence is an arbitrary sequenceDM30 of items which is already sorted according to the merge key specification for the corresponding merge source definition.
A merge key component specifies one component of a merge key specification; it corresponds to a single xsl:merge-key element in the stylesheet.
A merge key specification consists of one or more adjacent xsl:merge-key elements which together define how the merge input sequences selected by a merge source definition are sorted. Each xsl:merge-key element defines one merge key component.
For each item in a merge input sequence, a value is computed for each merge key component within the merge key specification. The value computed for an item by using the Nth merge key component is referred to as the Nth merge key value of that item.
A merge source definition is the definition of one kind of input to the merge operation. It selects zero or more merge input sequences, and it includes a merge key specification to define how the merge key values are computed for each such merge input sequence.
A mode is a set of template rules; when the xsl:apply-templates instruction selects a set of items for processing, it identifies the rules to be used for processing those items by nominating a mode, explicitly or implicitly.
All the xsl:mode declarations in a package that share the same name are grouped into a named mode definition; those that have no name are grouped into a single unnamed mode definition.
A motionless construct is any construct deemed motionless by the rules in this section (19 Streamability).
Templates can be invoked by name. An xsl:template element with a name attribute defines a named template.
The rules for the individual XSLT instructions that construct a result tree (see 11 Creating Nodes and Sequences) 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.
The native namespace bindings for any element in an XSLT stylesheet module are the prefix-uri mappings defined by the namespace nodes of that element, according to the rules in [XDM 3.0].
An operand usage of navigation indicates that the construct may navigate freely from the supplied node to other nodes in the same tree, in a way that is not constrained by the streamability rules.
A node pattern uses a subset of the syntax for path expressions, and is defined to match a node if the corresponding path expression would select the node. Node patterns may also be formed by combining other patterns using union, intersection, and difference operators.
The term non-contextual function call is used to refer to function calls that do not pass the dynamic context to the called function. This includes all calls on stylesheet functions and all dynamic function invocationsXP, (that is calls to function items as permitted by XPath 3.0). It excludes calls to some functions in the namespace http://www.w3.org/2005/xpath-functions, in particular those that explicitly depend on the context, such as the current-group and regex-group functions. It is implementation-defined whether, and under what circumstances, calls to extension functions are non-contextual.
A predicate is a non-positional predicate if it satisfies both of the following conditions:
The predicate does not contain a function call or named function reference to any of the following functions, unless that call or reference occurs within a nested predicate:
Note:
The exception for nested predicates is there to ensure that patterns such as match="p[@code = $status[last()]] are not disqualified.
The expression immediately contained in the predicate is a non-numeric expression. An expression is non-numeric if the intersection of its static type (see 19.1 Determining the Static Type of a Construct) with U{xs:decimal, xs:double, xs:float} is U{}.
A non-schema-aware processor is a processor that does not claim conformance with the schema-aware conformance feature. Such a processor must handle constructs associated with schema-aware processing as described in this section.
In an actual instance of a construct, there will be a number of operands. Each operand is itself a construct; the construct tree can be defined as the transitive relation between constructs and their operands.
For every construct kind, there is a set of zero or more operand roles.
The operand usage. This gives information, in the case where the operand value contains nodes, about how those nodes are used. The operand usage takes one of the values absorption, inspection, transmission, or navigation.
There is a total 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.
All the xsl:output declarations within a package 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.
Each instruction in the stylesheet is evaluated in one of two possible output states: final output state or temporary output state.
A component in a using package may override a component in a used package, provided that the visibility of the component in the used package is either abstract or public. The overriding declaration is written as a child of the xsl:override element, which in turn appears as a child of xsl:use-package.
An explicit package is represented by an xsl:package element, which will generally be the outermost element of an XML document. When the xsl:package element is not used explicitly, the entire stylesheet comprises a single implicit package.
The content of the xsl:package element is referred to as the package manifest
The xsl:param element declares a parameter, which may be a stylesheet parameter, a template parameter, a function parameter, or an xsl:iterate parameter. A parameter is a variable with the additional property that its value can be set by the caller.
A pattern specifies a set of conditions on an item. An item that satisfies the conditions matches the pattern; an item that does not satisfy the conditions does not match the pattern.
The picture string is the string supplied as the second argument of the format-number function.
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.
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.
The population is treated as a sequence; the order of items in this sequence is referred to as population order.
The integer literals and the optional NamePart within the version number are referred to as the portions of the version number.
The posture of the expression. This captures information about the way in which the streamed input document is positioned on return from evaluating the construct. The posture takes one of the values climbing, striding, crawling, roaming, or grounded.
An operand is potentially consuming if at least one of the following conditions applies:
The operand usage is transmission and the operand is not grounded.
A predicate pattern is written as . (dot) followed by zero or more predicates in square brackets, and it matches any item for which each of the predicates evaluates to true.
A principal result: this can be any sequence of items (as defined in [XDM 3.0]).
Within a package, one stylesheet module functions as the principal stylesheet module. The complete package is assembled by finding the stylesheet modules referenced directly or indirectly from the principal stylesheet module using xsl:include and xsl:import elements: see 3.11.2 Stylesheet Inclusion and 3.11.3 Stylesheet Import.
The priority of a template rule is specified by the priority attribute on the xsl:template declaration. If no priority is specified explicitly for a template rule, its default priority is used, as defined in 6.6 Default Priority for Template Rules.
There is another total 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.
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.
The result of invoking the selected component, after any required conversion to the declared result type of the component, is referred to as the raw result.
The process of identifying the component to which a symbolic reference applies (possibly chosen from several homonymous alternatives) is called reference binding.
The context within a stylesheet where an XPath expression appears may specify the required type of the expression. The required type indicates the type of the value that the expression is expected to return.
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.
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.
Roaming: indicates that the nodes returned by an expression could be anywhere in the tree, which inevitably means that the construct cannot be evaluated using streaming.
A RelativePathExpr is a scanning expression if and only if it is syntactically equivalent to some motionlesspattern.
A schema-aware XSLT processor is an XSLT processor that implements the mandatory requirements of this specification connected with the xsl:import-schema declaration, the [xsl:]validation and [xsl:]type attributes, and the ability to handle input documents whose nodes have type annotations other than xs:untyped and xs:untypedAtomic. The mandatory requirements of this specification are taken to include the mandatory requirements of XPath 3.0, as described in [XPath 3.0]. 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.
Type definitions and element and attribute declarations are referred to collectively as schema components.
The schema instance namespacehttp://www.w3.org/2001/XMLSchema-instance, with conventional prefix xsi, is used as defined in [XML Schema Part 1]
The schema namespacehttp://www.w3.org/2001/XMLSchema, with conventional prefix xs, is used as defined in [XML Schema Part 1]
Zero or more secondary results: each secondary result can be any sequence of items (as defined in [XDM 3.0]).
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, atomic items, and function items. The way that the resulting sequence is used depends on the containing instruction.
A SequenceType constrains the type and number of items in a sequence. The term is used both to denote the concept, and to refer to the syntactic form in which sequence types are expressed in the XPath grammar: specifically SequenceTypeXP in [XPath 3.0].
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.
If a transformation has successfully produced a principal result or secondary result, it is still possible that errors may occur in serializing that result . For example, it may be impossible to serialize the result using the encoding selected by the user. Such an error is referred to as a serialization error.
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 2726 Serialization.
Within a region of the stylesheet where a binding B1 is visible, B1 shadows another binding B2 having the same name as B1 if B1 occurs at a point where B2 is visible.
A simplified stylesheet, which is a subtree rooted at a literal result element, as described in 3.8 Simplified Stylesheet Modules. This is first converted to a standard stylesheet module by wrapping it in an xsl:stylesheet element using the transformation described in 3.8 Simplified Stylesheet Modules.
A singleton focus based on an item J has the context item (and therefore the context node, if J is a node) set to J, and the context position and context size both set to 1 (one).
A snapshot of a node N is a deep copy of N, as produced by the xsl:copy-of instruction with copy-namespaces set to yes, copy-accumulators set to yes, and validation set to preserve, with the additional property that for every ancestor of N, the copy also has a corresponding ancestor whose name, node-kind, and base URI are the same as the corresponding ancestor of N, and that has copies of the attributes, namespaces and accumulator values of the corresponding ancestor of N. But the ancestor has a type annotation of xs:anyType, has the properties nilled, is-id, and is-idref set to false, and has no children other than the child that is a copy of N or one of its ancestors.
The sequence after sorting as defined by the xsl:sort elements is referred to as the sorted sequence.
Within a sort key specification, each xsl:sort element defines one sort key component.
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.
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.
The term source tree means any tree provided as input to the transformation. This includes the document containing the global context item if any, documents containing nodes present in the initial match selection, documents containing nodes supplied as the values of stylesheet parameters, documents obtained from the results of functions such as document, doc, and collection, documents read using the xsl:source-document instruction, 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.
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.
There are a number of standard attributes that may appear on any XSLT element: specifically default-collation, default-mode, default-validation, exclude-result-prefixes, expand-text, extension-element-prefixes, use-when, version, and xpath-default-namespace.
The standard error namespacehttp://www.w3.org/2005/xqt-errors, with conventional prefix err, is used for error codes defined in this specification and related specifications. It is also used for the names of certain predefined variables accessible within the scope of an xsl:catch element.
The standard function namespacehttp://www.w3.org/2005/xpath-functions, with conventional prefix fn, is used for functions in the function library defined in [Functions and Operators 4.0] and for standard functions defined in this specification.
A standard stylesheet module, which is a subtree rooted at an xsl:stylesheet or xsl:transform element.
An error that can be 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.
A static expression is an XPath expression whose value must be computed during static analysis of the stylesheet.
A static variable declared using an xsl:param element is referred to as a static parameter.
The static type of a construct is such that all values produced by evaluating the construct will conform to that type. The static type of a construct is a U-type.
A top-levelvariable-binding element having the attribute static="yes" declares a static variable: that is, a global variable whose value is known during static analysis of the stylesheet.
Stylesheet functions belong to one of a number of streamability categories: the choice of category characterizes the way in which the function handles streamed input.
A streamable mode is a mode that is declared in an xsl:mode declaration with the attribute streamable="yes".
A streamed document is a source tree that is processed using streaming, that is, without constructing a complete tree of nodes in memory.
A streamed node is a node in a streamed document.
The term streaming refers to a manner of processing in which XML documents (such as source and result documents) are not represented by a complete tree of nodes occupying memory proportional to document size, but instead are processed “on the fly” as a sequence of events, similar in concept to the stream of events notified by an XML parser to represent markup in lexical XML.
A processor that claims conformance with the streaming featuremust use streamed processing in cases where (a) streaming is requested (for example by using the attribute streamable="yes" on xsl:mode, or on the xsl:source-document instruction) and (b) the constructs in question are guaranteed-streamable according to this specification.
The first parameter of a declared-streamablestylesheet function is referred to as a streaming parameter.
Striding: indicates that the result of a construct contains a sequence of streamed nodes, in document order, that are peers in the sense that none of them is an ancestor or descendant of any other.
The term string value is defined in Section 5.13 string-value Accessor DM30. 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.
A stylesheet consists of one or more packages: specifically, one top-level package and zero or more library packages.
An xsl:function declaration declares the name, parameters, and implementation of a family of stylesheet functions that can be called from any XPath expression within the stylesheet (subject to visibility rules).
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.
A package consists of one or more stylesheet modules, each one forming all or part of an XML document.
A top-levelxsl: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.
The value of the variable is computed using the expression given in the select attribute or the contained sequence constructor, as described in 9.3 Values of Variables and Parameters. This value is referred to as the supplied value of the variable.
Every construct has a sweep, which is a measure of the extent to which the current position in the input stream moves during the evaluation of the expression. The sweep is one of: motionless, consuming, or free-ranging .
The symbolic identifier of a component is a composite name used to identify the component uniquely within a package. The symbolic identifier comprises the kind of component (stylesheet function, named template, accumulator, attribute set, global variable, key, or mode), the expanded QName of the component (namespace URI plus local name), and in the case of stylesheet functions, the upper bound of the arity range.
The declaration of a component includes constructs that can be interpreted as references to other components by means of their symbolic identifiers. These constructs are generically referred to as symbolic references. Examples of constructs that give rise to symbolic references are the name attribute of xsl:call-template; the [xsl:]use-attribute-sets attribute of xsl:copy, xsl:element, and literal result elements; the explicit or implicit mode attribute of xsl:apply-templates; XPath variable references referring to global variables; XPath static function calls (including partial function applications) referring to stylesheet functions; and named function references (example: my:f#1) referring to stylesheet functions.
An instructionJ is in a tail position within a sequence constructorSC if it satisfies one of the following conditions:
J is the last instruction in SC, ignoring any xsl:fallback instructions.
J is in a tail position within the sequence constructor that forms the body of an xsl:if instruction that is itself in a tail position within SC.
J is in a tail position within the sequence constructor that forms the body of an xsl:when or xsl:otherwise branch of an xsl:chooseor xsl:switch instruction that is itself in a tail position within SC.
J is in a tail position within the sequence constructor that forms the body of an xsl:try instruction that is itself in a tail position within SC (that is, it is immediately followed by an xsl:catch element, ignoring any xsl:fallback elements).
J is in a tail position within the sequence constructor that forms the body of an xsl:catch element within an xsl:try instruction that is itself in a tail position within SC.
The string that results from evaluating the expression in the xpath attribute is referred to as the target expression.
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.
An xsl:template declaration defines a template, which contains a sequence constructor; this sequence constructor is evaluated to determine the result of the template. A template can serve either as a template rule, invoked by matching items 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.
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.
A stylesheet contains a set of template rules (see 6 Template Rules). A template rule has three parts: a pattern that is matched against selected items (often but not necessarily nodes), a (possibly empty) set of template parameters, and a sequence constructor that is evaluated to produce a sequence of items.
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.
The term temporary tree means any tree that is neither a source tree nor a final result tree.
In a text node that is designated as a text value template, expressions can be used by surrounding each expression with curly brackets ({}).
An element occurring as a child of an xsl:package, xsl:stylesheet, xsl:transform, or xsl:override element is called a top-level element.
For a given transformation, one package functions as the top-level package. The complete stylesheet is assembled by finding the packages referenced directly or indirectly from the top-level package using xsl:use-package declarations: see 3.5.2 Dependencies between Packages.
An operand usage of transmission indicates that the construct will (potentially) return a supplied node as part of its result to the calling construct (that is, to its parent in the construct tree).
A traversal of a tree is a sequence of traversal events.
a traversal event (shortened to event in this section) is a pair comprising a phase (start or end) and a node.
The term tree is used (as in [XDM 3.0]) to refer to the aggregate consisting of a parentless node together with all its descendant nodes, plus all their attributes and namespaces.
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.
The type-adjusted posture and sweep of a construct C, with respect to a type T, are the posture and sweep established by applying the general streamability rules to a construct D whose single operand is the construct C, where the operand usage of C in D is the type-determined usage based on the required type T.
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 Section 5.14 type-name Accessor DM30.
The type-determined usage of an operand is as follows: if the required type (ignoring occurrence indicator) is fn(*) or a subtype thereof, then inspection; if the required type (ignoring occurrence indicator) is an atomic or union type, then absorption; otherwise navigation.
The term typed value is defined in Section 5.15 typed-value Accessor DM30. Every node, other than an element whose type annotation identifies it as having 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.
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.
A type pattern can be written as type(T) (where T is an ItemTypeXP followed by zero or more predicates in square brackets, and it matches any item of type T which each of the predicates evaluates to true.
The unnamed mode is the default mode used when no mode attribute is specified on an xsl:apply-templates instruction or xsl:template declaration, unless a different default mode has been specified using the [xsl:]default-mode attribute of a containing element.
Within this specification, the term URI Reference, unless otherwise stated, refers to a string in the lexical space of the xs:anyURI datatype as defined in [XML Schema Part 2].
If a package Q contains an xsl:use-package element that references package P, then package Q is said to use package P. In this relationship package Q is referred to as the using package, package P as the used package.
In addition to declarations, the xsl:stylesheet element may contain among its children 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.
A U-type is a set of fundamental item types.
An item is vacuous if it is one of the following: a zero-length text node; a document node with no children; an atomic item which, on casting to xs:string, produces a zero-length string; or an array which on flattening using the array:flatten function produces either an empty sequence or a sequence consisting entirely of vacuous items.
A variable is a binding between a name and a value. The value of a variable is any sequence (of nodes, atomic items, and/or function items), as defined in [XDM 3.0].
Collectively, attribute value templates and text value templates are referred to as value templates.
The xsl:variable element declares a variable, which may be a global variable or a local variable.
The two elements xsl:variable and xsl:param are referred to as variable-binding elements.
The visibility of a component is one of: private, public, abstract, final, or hidden.
A whitespace text node is a text node whose content consists entirely of whitespace characters (that is, U+0009 (TAB) , U+000A (NEWLINE) , U+000D (CARRIAGE RETURN) , or U+0020 (SPACE) ).
The XML namespace, defined in [Namespaces in XML] as http://www.w3.org/XML/1998/namespace, is used for attributes such as xml:lang, xml:space, and xml:id.
The term XPath 1.0 compatibility mode is defined in Section 2.2.1 Static ContextXP. 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 4.0 and XPath 1.0.
An element in the stylesheet is processed with XSLT 1.0 behavior if its effective version is equal to 1.0.
A processor that claims conformance with the XSLT 1.0 compatibility featuremust support the processing of stylesheet instructions and XPath expressions with XSLT 1.0 behavior, as defined in 3.9 Backwards Compatible Processing.
An element is processed with XSLT 2.0 behavior if its effective version is equal to 2.0.
An element is processed with XSLT 3.0 behavior if its effective version is equal to 3.0.
An XSLT element is an element in the XSLT namespace whose syntax and semantics are defined in this specification.
An XSLT instruction is an XSLT element whose syntax summary in this specification contains the annotation <!-- category: instruction -->.
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.
The syntax of each XSLT element is summarized below, together with the context in the stylesheet where the element may appear. Some elements (specifically, instructions) are allowed as a child of any element that is allowed to contain a sequence constructor. These elements are:
Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Model:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Category: declaration Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Model:
|
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Model:
|
Category: instruction Model:
Permitted parent elements:
|
Category: declaration Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Category: declaration instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
Model:
Permitted parent elements: |
Category: instruction Model:
Permitted parent elements:
|
Model:
Permitted parent elements: |
This appendix provides a summary of error conditions that a processor may raise. This list includes all error codes defined in this specification, but this is not an exhaustive list of all errors that can occur. Implementations must raise errors using these error codes, and applications can test for these codes; however, when more than one rule in the specification is violated, different processors will not necessarily raise the same error code. Implementations are not required to raise errors using the descriptive text used here.
Note:
The appendix is non-normative because the same information is given normatively elsewhere.
Static errors
It is a static error if an XSLT-defined element is used in a context where it is not permitted, if a required attribute is omitted, or if the content of the element does not correspond to the content that is allowed for the element.
It is a static error if an attribute (other than an attribute written using curly brackets in a position where an attribute value template is permitted) contains a value that is not one of the permitted values for that attribute.
It is a static error to use a reserved namespace in the name of a named template, a mode, an attribute set, a key, a decimal-format, a variable or parameter, a stylesheet function, a named output definition, an accumulator, or a character map; except that the name xsl:initial-template is permitted as a template name.
It is a static error to use a reserved namespace in the name of any extension function or extension instruction, other than a function or instruction defined in this specification or in a normatively referenced specification. It is a static error to use a prefix bound to a reserved namespace in the [xsl:]extension-element-prefixes attribute.
It is a static error for an element from the XSLT namespace to have an attribute whose namespace is either null (that is, an attribute with an unprefixed name) or the XSLT namespace, other than attributes defined for the element in this document.
The value of the version attribute must be a number: specifically, it must be a valid instance of the type xs:decimal as defined in [XML Schema Part 2].
An xsl:stylesheet, xsl:transform, or xsl:package element must not have any text node children.
It is a static error if a token appearing in the fixed-namespaces attribute takes a form that is not one of the permitted forms, or if it is interpreted as a URI but cannot be dereferenced to locate a namespace well-formed XML document. It is not permitted to bind the prefix xmlns. It is not permitted to bind the prefix xml or the XML namespace URI http://www.w3.org/XML/1998/namespace, other than to each other.
It is a static error if the value of an [xsl:]default-collation attribute, after resolving against the base URI, contains no URI that the implementation recognizes as a collation URI.
It is a static error if an xsl:stylesheet, xsl:transform, or xsl:package element has a child element whose name has a null namespace URI.
It is a static error if the processor is not able to retrieve the resource identified by the URI reference [ in the href attribute of xsl:include or xsl:import ] , or if the resource that is retrieved does not contain a stylesheet module.
An xsl:include element must be a top-level element.
An xsl:import element must be a top-level element.
It is a static error if a stylesheet module directly or indirectly references itself via a chain of xsl:include and xsl:import declarations that contains at least one xsl:import.
It is a static error if an xsl:import-schema element that contains an xs:schema element has a schema-location attribute, or if it has a namespace attribute that conflicts with the target namespace of the contained schema.
It is a static error if the synthetic schema document does not satisfy the constraints described in [XML Schema Part 1] (section 5.1, Errors in Schema Construction and Structure). This includes, without loss of generality, conflicts such as multiple definitions of the same name.
Within an XSLT element that is required to be empty, any content other than comments or processing instructions, including any whitespace text node preserved using the xml:space="preserve" attribute, is a static error.
It is a static error if there is a stylesheet module in a package that specifies input-type-annotations="strip" and another stylesheet module that specifies input-type-annotations="preserve", or if a stylesheet module specifies the value strip or preserve and the same value is not specified on the xsl:package element of the containing package.
It is a static error if within any package the same NameTestXP appears in both an xsl:strip-space and an xsl:preserve-space declaration if both have the same import precedence. Two NameTests are considered the same if they match the same set of names (which can be determined by comparing them after expanding namespace prefixes to URIs).
In the case of a prefixed lexical QName used as the value (or as part of the value) of an attribute in the stylesheet, or appearing within an XPath expression in the stylesheet, it is a static error if the defining element has no namespace node whose name matches the prefix of the lexical QName.
Where an attribute is defined to contain a pattern, it is a static error if the pattern does not match the production Pattern40.
It is a static error if an unescaped left curly bracket appears in a fixed part of a value template without a matching right curly bracket.
It is a static error if an unescaped right curly bracket occurs in a fixed part of a value template.
An xsl:template element must have either a match attribute or a name attribute, or both. An xsl:template element that has no match attribute must have no mode attribute and no priority attribute. An xsl:template element that has no name attribute must have no visibility attribute.
The value of the priority attribute [ of the xsl:template element] must conform to the rules for the xs:decimal type defined in [XML Schema Part 2]. Negative values are permitted.
It is a static error if for any named or unnamed mode, a package explicitly specifies two conflicting values for the same attribute in different xsl:mode declarations having the same import precedence, unless there is another definition of the same attribute with higher import precedence. The attributes in question are the attributes other than name on the xsl:mode element.
It is a static error if the list of modes [in the mode attribute of xsl:template ] is empty, if the same token is included more than once in the list, if the list contains an invalid token, or if the token #all appears together with any other value.
It is a static error if the values of the name attribute of two sibling xsl:param elements represent the same expanded QName.
It is a static error if a variable-binding element has a select attribute and has non-empty content.
It is a static error if a package contains more than one non-hidden binding of a global variable with the same name and same import precedence, unless it also contains another binding with the same name and higher import precedence.
It is a static error if a package contains an xsl:call-template instruction whose name attribute does not match the name attribute of any named template visible in the containing package (this includes any template defined in this package, as well as templates accepted from used packages whose visibility in this package is not hidden). For more details of the process of binding the called template, see 3.5.3.5 Binding References to Components.
It is a static error if a package contains more than one non-hidden template with the same name and the same import precedence, unless it also contains a template with the same name and higher import precedence.
It is a static error if two or more sibling xsl:with-param elements have name attributes that represent the same expanded QName.
In the case of xsl:call-template, it is a static error to pass a non-tunnel parameter named x to a template that does not have a non-tunnel template parameter named x, unless the xsl:call-template instruction is processed with XSLT 1.0 behavior.
It is a static error if a package contains both (a) a named template named T that is not overridden by another named template of higher import precedence and that has an explicitly mandatory non-tunnel parameter named P, and (b) an xsl:call-template instruction whose name attribute equals T and that has no non-tunnel xsl:with-param child element whose name attribute equals P. (All names are compared as QNames.)
It is a static error if the value of the use-attribute-sets attribute of an xsl:copy, xsl:element, or xsl:attribute-set element, or the xsl:use-attribute-sets attribute of a literal result element, is not a whitespace-separated sequence of EQNames, or if it contains an EQName that does not match the name attribute of any xsl:attribute-set declaration in the containing package.
If an xsl:attribute set element specifies streamable="yes" then every attribute set referenced in its use-attribute-sets attribute (if present) must also specify streamable="yes".
It is a static error if a stylesheet function has a name that is in no namespace.
It is a static error if an xsl:param child of an xsl:function element has either a select attribute or non-empty content, unless it specifies required="no".
It is a static error if an xsl:param child of an xsl:function element specifies required="no", unless all following-sibling xsl:param elements also specify required="no".
It is a static error for a package to contain an xsl:function declaration F and an xsl:function declaration G such that F and G have the same expanded QName, F has lower import precedence than G, and the arity range of G includes part but not all of the arity range of F, unless G is itself eclipsed by another xsl:function declaration.
It is a static error for a package to contain an xsl:function declaration F and an xsl:function declaration G such that F and G have the same expanded QName and the same import precedence, if the arity ranges of F and G overlap in whole or in part, unless F and G are both eclipsed by another xsl:function declaration.
It is a static error if an attribute on a literal result element is in the XSLT namespace, unless it is one of the attributes explicitly defined in this specification.
It is a static error if a namespace prefix is used within the [xsl:]exclude-result-prefixes attribute and there is no namespace binding in scope for that prefix.
It is a static error if the value #default is used within the [xsl:]exclude-result-prefixes attribute and the parent element of the [xsl:]exclude-result-prefixes attribute has no default namespace.
It is a static error if within a package there is more than one such declaration [more than one xsl:namespace-alias declaration] with the same literal namespace URI and the same import precedence and different values for the target namespace URI, unless there is also an xsl:namespace-alias declaration with the same literal namespace URI and a higher import precedence.
It is a static error if a value other than #default is specified for either the stylesheet-prefix or the result-prefix attributes of the xsl:namespace-alias element when there is no in-scope binding for that namespace prefix.
It is a static error if the select attribute of the xsl:attribute element is present unless the element has empty content.
It is a static error if the select attribute of the xsl:value-of element is present when the content of the element is non-empty.
It is a static error if the select attribute of the xsl:processing-instruction element is present unless the element has empty content.
It is a static error if the select attribute of the xsl:namespace element is present when the element has content other than one or more xsl:fallback instructions, or if the select attribute is absent when the element has empty content.
It is a static error if the select attribute of the xsl:comment element is present unless the element has empty content.
It is a static error if the value attribute of xsl:number is present unless the select, level, count, and from attributes are all absent.
It is a static error if an xsl:sort element with a select attribute has non-empty content.
It is a static error if an xsl:sort element other than the first in a sequence of sibling xsl:sort elements has a stable attribute.
It is a static error if an xsl:perform-sort instruction with a select attribute has any content other than xsl:sort and xsl:fallback instructions.
It is a static error if the current-group function is used within a pattern.
It is a static error if the current-grouping-key function is used within a pattern.
These five attributes [the group-by, group-adjacent, group-starting-with, group-ending-with, and split-when attributes of xsl:for-each-group ] are mutually exclusive: it is a static error if none of these attributes is present or if more than one of them is present.
It is a static error to specify the collation attribute or the composite attribute if neither the group-by attribute nor group-adjacent attribute is specified.
It is a static error if the xsl:analyze-string instruction contains neither an xsl:matching-substring nor an xsl:non-matching-substring element.
It is a static error if an xsl:key declaration has a use attribute and has non-empty content, or if it has empty content and no use attribute.
It is a static error if the xsl:key declaration has a collation attribute whose value (after resolving against the base URI) is not a URI recognized by the implementation as referring to a collation.
It is a static error if there are several xsl:key declarations in the same package with the same key name and different effective collations. Two collations are the same if their URIs are equal under the rules for comparing xs:anyURI values, or if the implementation can determine that they are different URIs referring to the same collation.
It is a static error if there are several xsl:key declarations in a package with the same key name and different effective values for the composite attribute.
It is a static error if a named or unnamed decimal format contains two conflicting values for the same attribute in different xsl:decimal-format declarations having the same import precedence, unless there is another definition of the same attribute with higher import precedence.
It is a static error if the character specified in the zero-digit attribute is not a digit or is a digit that does not have the numeric value zero.
It is a static error if, for any named or unnamed decimal format, the properties identifying marker characters to be used in a picture string do not identify distinct values. These properties are decimal-separator, grouping-separator, exponent-separator, percent, per-mille, zero-digit, digit, and pattern-separator.
It is a static error if there is no namespace bound to the prefix on the element bearing the [xsl:]extension-element-prefixes attribute or, when #default is specified, if there is no default namespace.
It is a static error if both the [xsl:]type and [xsl:]validation attributes are present on the xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, xsl:document, xsl:result-document, xsl:source-document, or xsl:merge-source elements, or on a literal result element.
It is a static error if the value of the type attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, xsl:document, xsl:result-document, xsl:source-document, or xsl:merge-source instruction, or the xsl:type attribute of a literal result element, is not a valid QName, or if it uses a prefix that is not defined in the applicable static namespaces of the containing instruction, or if the QName is not the name of a type definition included in the in-scope schema components for the package. [XSLT 3.0 Erratum E20, bug 30234]
It is a static error if the value of the type attribute of an xsl:attribute instruction refers to a complex type definition
It is a static error if two xsl:output declarations within an output definition specify explicit values for the same attribute (other than cdata-section-elements, suppress-indentation, and use-character-maps), with the values of the attributes being not equal, unless there is another xsl:output declaration within the same output definition that has higher import precedence and that specifies an explicit value for the same attribute.
The value [of the method attribute on xsl:output ] must (if present) be a valid EQName. If it is a lexical QName with no a prefix, then it identifies a method specified in [XSLT and XQuery Serialization] and must be one of xml, html, xhtml, or text.
It is a static error if a package contains two or more character maps with the same name and the same import precedence, unless it also contains another character map with the same name and higher import precedence.
It is a static error if a name in the use-character-maps attribute of the xsl:output or xsl:character-map elements does not match the name attribute of any xsl:character-map in the containing package.
It is a static error if a character map references itself, directly or indirectly, via a name in the use-character-maps attribute.
A non-schema-aware processormust raise a static error if a package includes an xsl:import-schema declaration.
A non-schema-aware processormust raise a static error if a package includes an [xsl:]type attribute; or an [xsl:]validation or [xsl:]default-validation attribute with a value other than strip, preserve, or lax; or an xsl:mode element whose typed attribute is equal to yes or strict; or an as attribute whose value is a SequenceType that can only match nodes with a type annotation other than xs:untyped or xs:untypedAtomic (for example, as="element(*, xs:integer)").
It is a static error if the number of xsl:merge-key children of a xsl:merge-source element is not equal to the number of xsl:merge-key children of another xsl:merge-source child of the same xsl:merge instruction.
It is a static error if no package matching the package name and version specified in an xsl:use-package declaration can be located.
It is a static error if a package is dependent on itself, where package A is defined as being dependent on package B if A contains an xsl:use-package declaration that references B, or if A contains an xsl:use-package declaration that references a package C that is itself dependent on B.
It is a static error if an xsl:use-package declaration appears in a stylesheet module that is not in the same stylesheet level as the principal stylesheet module of the package.
It is a static error if the explicit exposed visibility of a component is inconsistent with its declared visibility, as defined in the above table. (This error occurs only when the component declaration has an explicit visibility attribute, and the component is also listed explicitly by name in an xsl:expose declaration.)
It is a static error if a token in the names attribute of xsl:expose, other than a wildcard, matches no component in the containing package.
It is a static error if the component attribute of xsl:expose specifies * (meaning all component kinds) and the names attribute is not a wildcard.
It is a static error if the effect of an xsl:expose declaration would be to make a component abstract, unless the component is already abstract in the absence of the xsl:expose declaration.
It is a static error if a token in the names attribute of xsl:accept, other than a wildcard, matches no component in the used package.
It is a static error if the component attribute of xsl:accept specifies * (meaning all component kinds) and the names attribute is not a wildcard.
It is a static error if the visibility assigned to a component by an xsl:accept element is incompatible with the visibility of the corresponding component in the used package, as defined by the above table, unless the token that matches the component name is a wildcard, in which case the xsl:accept element is treated as not matching that component.
It is a static error if the xsl:use-package elements in a package manifest cause two or more homonymous components to be accepted with a visibility other than hidden.
It is a static error if a token in the names attribute of xsl:accept, other than a wildcard, matches the symbolic name of a component declared within an xsl:override child of the same xsl:use-package element.
It is a static error if a component declaration appearing as a child of xsl:override is homonymous with any other declaration in the using package, regardless of import precedence, including any other overriding declaration in the package manifest of the using package.
It is a static error if a component declaration appearing as a child of xsl:override does not match (is not homonymous with) some component in the used package.
It is a static error if the component referenced by an xsl:override declaration has visibility other than public or abstract
It is a static error if the signature of an overriding component is not compatible with the signature of the component that it is overriding.
It is a static error to use the component reference xsl:original when the overridden component has visibility="abstract".
It is a static error if a top-level package (as distinct from a library package) contains components whose visibility is abstract.
It is a static error, when the effective value of the declared-modes attribute of an xsl:package element is yes, if the package contains an explicit reference to an undeclared mode, or if it implicitly uses the unnamed mode and the unnamed mode is undeclared.
It is a static error if more than one xsl:global-context-item declaration appears within a stylesheet module, or if several modules within a single package contain inconsistent xsl:global-context-item declarations
It is a static error if the as attribute is present [on the xsl:context-item element] when use="absent" is specified.
It is a static error if the as attribute is present [on the xsl:global-context-item element] when use="absent" is specified.
It is a static error if a template rule applicable to a mode that is defined with typed="strict" uses a match pattern that contains a RelativePathExprP whose first StepExprP is an AxisStepP whose ForwardStepP uses an axis whose principal node kind is Element and whose NodeTest is an EQName that does not correspond to the name of any global element declaration in the in-scope schema components.
It is a static error if an xsl:break or xsl:next-iteration element appears other than in a tail position within the sequence constructor forming the body of an xsl:iterate instruction.
It is a static error if the select attribute of xsl:break or xsl:on-completion is present and the instruction has children.
It is a static error if the name attribute of an xsl:with-param child of an xsl:next-iteration element does not match the name attribute of an xsl:param child of the innermost containing xsl:iterate instruction.
It is a static error if the select attribute of the xsl:try element is present and the element has children other than xsl:catch and xsl:fallback elements.
It is a static error if the select attribute of the xsl:catch element is present unless the element has empty content.
For the elements xsl:sequence, xsl:on-empty, xsl:on-non-empty, xsl:when, xsl:otherwise, xsl:matching-substring, xsl:non-matching-substring, xsl:map, xsl:map-entry, xsl:array, xsl:array-member, and xsl:result-document, it is a static error if the select attribute is present and the instruction has children other than xsl:fallback.
It is a static error if two sibling xsl:merge-source elements have the same name.
If the for-each-item attribute is present then the for-each-source, use-accumulators, and streamable attributes must all be absent. If either or both of the use-accumulators or streamable attributes is present then the for-each-source attribute must be present. If the for-each-source attribute is present then the for-each-item attribute must be absent. [XSLT 3.0 Erratum E40, bugs 30265 and 30378].
It is a static error if an xsl:merge-key element with a select attribute has non-empty content.
It is a static error if the list of accumulator names [in the use-accumulators attribute] contains an invalid token, contains the same token more than once, or contains the token #all along with any other value; or if any token (other than #all) is not the name of a declared-streamable accumulator visible in the containing package.
It is a static error for a package to contain two or more accumulators with the same expanded QName and the same import precedence, unless there is another accumulator with the same expanded QName, and a higher import precedence.
It is a static error for a an xsl:accumulator-rule element to specify capture="yes" unless it also specifies phase="end".
It is a static error if a package contains a construct that is declared to be streamable but which is not guaranteed-streamable, unless the user has indicated that the processor is to handle this situation by processing the stylesheet without streaming or by making use of processor extensions to the streamability rules where available.
In the case of a template rule (that is, an xsl:template element having a match attribute) appearing as a child of xsl:override, it is a static error if the list of modes in the mode attribute contains #all or #unnamed, or if it contains #default and the default mode is the unnamed mode, or if the mode attribute is omitted when the default mode is the unnamed mode.
It is a static error if a variable declared with static="yes" is inconsistent with another static variable of the same name that is declared earlier in stylesheet tree order and that has lower import precedence.
It is a static error if an xsl:apply-imports element appears in a template rule declared within an xsl:override element. (To invoke the template rule that is being overridden, xsl:next-match should therefore be used.)
It is a static error if the current-merge-group function is used within a pattern.
It is a static error if the current-merge-key-array or current-merge-key function is used within a pattern.
It is a static error if a parameter to xsl:iterate is implicitly mandatory.
It is a static error if an xsl:mode declaration with one or more xsl:template children has no name attribute.
It is a static error if an xsl:mode declaration has a child xsl:template element with a name attribute, with a mode attribute, or with no match attribute.
It is a static error if an xsl:mode declaration having one or more child xsl:template elements has a default-mode attribute whose value differs from its name attribute, or if any of those child xsl:template elements has a default-mode attribute that differs from the name attribute of the xsl:mode declaration.
It is a static error if a package contains both (a) an xsl:mode declaration having one or more child xsl:template elements, and (b) an xsl:template declaration that is not one of those children but that references that xsl:mode declaration in its mode attribute.
It is a static error if a package contains (a) an xsl:mode declaration having one or more child xsl:template elements, and (b) a second xsl:mode declaration having the same name and the same import precedence.
It is a static error if a package contains two xsl:item-type or xsl:record-type declarations having the same name and the same import precedence, unless there is another definition with the same name and higher import precedence. It is also a static error if the name of the item type uses a reserved namespace, or if it has the same name as a type in the in-scope schema typesXP of the static context.
It is a static error if a package contains two xsl:record-type declarations having the same import precedence, unless there is another definition of the same record type with higher import precedence.
It is a static error for an item type named N to contain in its as attribute a reference to N, or to an item type that references N directly or indirectly.
It is a static error for an item type named N to contain in its as attribute a reference to N, or to an item type that references N directly or indirectly, unless it satisfies the conditions defined in Section 3.2.8.3.1 Recursive Record TypesXP.
It is a static error if a template ruleR has an as attribute S, and the template rule is applicable to a modeM that is declared with an as attribute T, and the sequence type S is not a subtype of the sequence type T as defined by the relationship subtype(S, T) in Section 3.3.1 Subtypes of Sequence TypesXP.
Type errors
It is a type error if the result sequence contains a function item.
It is a type error if the result of evaluating the sequence constructor cannot be coerced to the required type.
It is a type error if an xsl:apply-templates instruction with no select attribute is evaluated when the context item is not a node.
It is a type error if the supplied value of a variable cannot be converted to the required type.
It is a type error if the conversion of the supplied value of a parameter, or of the context item, does not match the required type, after applying any permitted conversions. [XSLT 3.0 Erratum E22, bug 30238].
If the as attribute [of xsl:function ] is specified, then the result evaluated by the sequence constructor (see 5.8 Sequence Constructors) is converted to the required type, using the coercion rules. It is a type error if this conversion fails.
It is a type error to use the xsl:copy instruction with no select attribute when the context item is absent.
It is a type error to use the xsl:copy or xsl:copy-of instruction to copy a node that has namespace-sensitive content if the copy-namespaces attribute has the value no and its explicit or implicit validation attribute has the value preserve. It is also a type error if either of these instructions (with validation="preserve") is used to copy an attribute having namespace-sensitive content, unless the parent element is also copied. A node has namespace-sensitive content if its typed value contains an item of type xs:QName or xs:NOTATION or a type derived therefrom. The reason this is an error is because the validity of the content depends on the namespace context being preserved.
It is a type error if the xsl:number instruction is evaluated, with no value or select attribute, when the context item is not a node.
It is a type error if the result of evaluating the select attribute of the xsl:number instruction is anything other than a single node.
It is a type error if the result of evaluating the group-adjacent expression is an empty sequence or a sequence containing more than one item, unless composite="yes" is specified.
If the validation attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, or xsl:result-document instruction, or the xsl:validation attribute of a literal result element, has the effective valuestrict, and schema validity assessment concludes that the validity of the element or attribute is invalid or unknown, a type error occurs. As with other type errors, the error may be raised statically if it can be detected statically.
If the validation attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, or xsl:result-document instruction, or the xsl:validation attribute of a literal result element, has the effective valuestrict, and there is no matching top-level declaration in the schema, then a type error occurs. As with other type errors, the error may be raised statically if it can be detected statically.
If the validation attribute of an xsl:element, xsl:attribute, xsl:copy, xsl:copy-of, or xsl:result-document instruction, or the xsl:validation attribute of a literal result element, has the effective valuelax, and schema validity assessment concludes that the element or attribute is invalid, a type error occurs. As with other type errors, the error may be raised statically if it can be detected statically.
It is a type error if the value of the type attribute of an xsl:copy or xsl:copy-of instruction refers to a complex type definition and one or more of the items being copied is an attribute node.
It is a type error if an [xsl:]type attribute is defined for a constructed element or attribute, and the outcome of schema validity assessment against that type is that the validity property of that element or attribute information item is other than valid.
A type error occurs if a type or validation attribute is defined (explicitly or implicitly) for an instruction that constructs a new attribute node, if the effect of this is to cause the attribute value to be validated against a type that is derived from, or constructed by list or union from, the primitive types xs:QName or xs:NOTATION.
A type error occurs [when a document node is validated] unless the children of the document node comprise exactly one element node, no text nodes, and zero or more comment and processing instruction nodes, in any order.
It is a type error if, when validating a document node, document-level constraints (such as ID/IDREF constraints) are not satisfied.
It is a type error if some item selected by a particular merge key in one input sequence is not comparable using the XPath le operator with the corresponding item selected by the corresponding sort key in another input sequence.
It is a type error if the xsl:context-item child of xsl:template specifies that a context item is required and none is supplied by the caller, that is, if the context item is absent at the point where xsl:call-template is evaluated.
It is a type error if an xsl:apply-templates instruction in a particular mode selects an element or attribute whose type is xs:untyped or xs:untypedAtomic when the typed attribute of that mode specifies the value yes, strict, or lax.
It is a type error if an xsl:apply-templates instruction in a particular mode selects an element or attribute whose type is anything other than xs:untyped or xs:untypedAtomic when the typed attribute of that mode specifies the value no.
It is a type error if the result of evaluating the expression in the with-params attribute of the xsl:evaluate instruction is anything other than a single map of type map(xs:QName, item()*).
It is a type error if the result of evaluating the namespace-context attribute of the xsl:evaluate instruction is anything other than a single node.
It is a type error if the result of evaluating the select expression [of the xsl:copy element] is a sequence of more than one item.
A type error occurs if the result of the input sequence [of an xsl:map instruction] is not an instance of the required type map(*)*.
A type error is raised if the result of evaluating the select expression or contained sequence constructor of an xsl:array instruction is not an instance of one of the following sequence types: empty-sequence(), xs:anyAtomicType+, node()+, or record(value as item()*, *)+. As with other type errors, the error may be raised statically if it can be detected statically.
Dynamic errors
It is a dynamic error if the effective value of an attribute written using curly brackets, in a position where an attribute value template is permitted, is a value that is not one of the permitted values for that attribute. If the processor is able to detect the error statically (for example, when any XPath expressions within the curly brackets can be evaluated statically), then the processor may optionally raise this as a static error.
It is a dynamic error if the invocation of the stylesheet specifies a template name that does not match the expanded QName of a named template defined in the stylesheet, whose visibility is public or final.
It is a dynamic error if the invocation of the stylesheet specifies a function name and arity that does not match the expanded QName and arity of a named stylesheet function defined in the stylesheet, whose visibility is public or final.
It is a dynamic error if the invocation of the stylesheet specifies an initial mode when no initial match selection is supplied (either explicitly, or defaulted to the global context item).
It is a dynamic error if the invocation of the stylesheet specifies an initial mode and the specified mode is not eligible as an initial mode (as defined above).
It is a dynamic error if a stylesheet declares a visible stylesheet parameter that is explicitly or implicitly mandatory, and no value for this parameter is supplied when the stylesheet is primed. A stylesheet parameter is visible if it is not masked by another global variable or parameter with the same name and higher import precedence. If the parameter is a static parameter then the value must be supplied prior to the static analysis phase.
It is a dynamic error if an element has an effective version of V (with V < 4.0) when the implementation does not support backwards compatible behavior for XSLT version V.
Where the result of evaluating an XPath expression (or an attribute value template) is required to be a lexical QName, or if it is permitted to be a lexical QName and the actual value takes the form of a lexical QName, then unless otherwise specified it is a dynamic error if the value has a prefix and the defining element has no namespace node whose name matches that prefix. This error may be raised as a static error if the value of the expression can be determined statically.
It is a dynamic error if the sequence used to construct the content of an element node contains a namespace node or attribute node that is preceded in the sequence by a node that is neither a namespace node nor an attribute node.
It is a dynamic error if the sequence used to construct the content of a document node contains a namespace node or attribute node.
It is a dynamic error if the sequence contains two or more namespace nodes having the same name but different string values (that is, namespace nodes that map the same prefix to different namespace URIs).
It is a dynamic error if the sequence contains a namespace node with no name and the element node being constructed has a null namespace URI (that is, it is an error to define a default namespace when the element is in no namespace).
It is a dynamic error if the conflict resolution algorithm for template rules leaves more than one matching template rule when the declaration of the relevant mode has an on-multiple-match attribute with the value fail.
It is a dynamic error if xsl:apply-templates, xsl:apply-imports or xsl:next-match is used to process an item using a mode whose declaration specifies on-no-match="fail" when there is no template rule in the stylesheet whose match pattern matches that item.
It is a dynamic error if xsl:apply-imports or xsl:next-match is evaluated when the current template rule is absent.
In general, a circularity in a stylesheet is a dynamic error.
It is a dynamic error if a template that has an explicitly mandatory or implicitly mandatory parameter is invoked without supplying a value for that parameter.
It is a dynamic error if the effective value of the name attribute [of the xsl:element instruction] is not a lexical QName.
In the case of an xsl:element instruction with no namespace attribute, it is a dynamic error if the effective value of the name attribute is a lexical QName whose prefix is not declared in the applicable static namespaces for the xsl:element instruction.
It is a dynamic error if the effective value of the namespace attribute [of the xsl:element instruction] is not in the lexical space of the xs:anyURI datatype or if it is the string http://www.w3.org/2000/xmlns/.
It is a dynamic error if the effective value of the name attribute [of an xsl:attribute instruction] is not a lexical QName.
In the case of an xsl:attribute instruction with no namespace attribute, it is a dynamic error if the effective value of the name attribute is the string xmlns.
In the case of an xsl:attribute instruction with no namespace attribute, it is a dynamic error if the effective value of the name attribute is a lexical QName whose prefix is not declared in the applicable static namespaces for the xsl:attribute instruction.
It is a dynamic error if the effective value of the namespace attribute [of the xsl:attribute instruction] is not in the lexical space of the xs:anyURI datatype or if it is the string http://www.w3.org/2000/xmlns/.
It is a dynamic error if the effective value of the name attribute [of the xsl:processing-instruction instruction] is not both an NCNameNames and a PITargetXML.
It is a dynamic error if the string value of the new namespace node is not valid in the lexical space of the datatype xs:anyURI, or if it is the string http://www.w3.org/2000/xmlns/.
It is a dynamic error if the effective value of the name attribute [of the xsl:namespace instruction] is neither a zero-length string nor an NCNameNames, or if it is xmlns.
It is a dynamic error if the xsl:namespace instruction generates a namespace node whose name is xml and whose string value is not http://www.w3.org/XML/1998/namespace, or a namespace node whose string value is http://www.w3.org/XML/1998/namespace and whose name is not xml.
It is a dynamic error if evaluating the select attribute or the contained sequence constructor of an xsl:namespace instruction results in a zero-length string.
It is a dynamic error if any undiscarded item in the atomized sequence supplied as the value of the value attribute of xsl:number cannot be converted to an integer, or if the resulting integer is less than 0 (zero).
It is a dynamic error if, for any sort key component, the set of sort key values evaluated for all the items in the initial sequence, after any type conversion requested, contains a pair of atomic items for which the result of the XPath lt operator is an error. If the processor is able to detect the error statically, it may optionally raise it as a static error.
It is a dynamic error if the collation attribute of xsl:sort (after resolving against the base URI) is not a URI that is recognized by the implementation as referring to a collation.
It is a dynamic error if the current-group function is used when the current group is absent , or when it is invoked in the course of evaluating a pattern. The error may be reported statically if it can be detected statically.
It is a dynamic error if the current-grouping-key function is used when the current grouping key is absent, or when it is invoked in the course of evaluating a pattern. The error may be reported statically if it can be detected statically.
It is a dynamic error if the collation URI specified to xsl:for-each-group (after resolving against the base URI) is a collation that is not recognized by the implementation. (For notes, [see ERR XTDE1035].)
It is a dynamic error if the effective value of the regex attribute [of the xsl:analyze-string instruction] does not conform to the required syntax for regular expressions, as specified in [Functions and Operators 4.0]. If the regular expression is known statically (for example, if the attribute does not contain any expressions enclosed in curly brackets) then the processor may raise the error as a static error.
It is a dynamic error if the effective value of the flags attribute [of the xsl:analyze-string instruction] has a value other than the values defined in [Functions and Operators 4.0]. If the value of the attribute is known statically (for example, if the attribute does not contain any expressions enclosed in curly brackets) then the processor may raise the error as a static error.
When a URI reference [supplied to the document function] contains a fragment identifier, it is a dynamic error if the media type is not one that is recognized by the processor, or if the fragment identifier does not conform to the rules for fragment identifiers for that media type, or if the fragment identifier selects something other than a sequence of nodes (for example, if it selects a range of characters within a text node).
When a URI reference [supplied to the document function] is a relative reference, it is a dynamic error if no base URI is available to resolve the relative reference. This can arise for example when the URI is contained in a node that has no base URI (for example a parentless text node), or when the second argument to the function is a node that has no base URI, or when the base URI from the static context is undefined.
It is a dynamic error if the value of $key-name is not a valid QName, or if there is no namespace declaration in scope for the prefix of the QName, or if the name obtained by expanding the QName is not the same as the expanded name of any xsl:key declaration in the containing package. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
It is a dynamic error if the key identified in a call to the function map-for-key is unsuitable because it uses a collation other than the Unicode Codepoint Collation, or because it is defined with composite=yes.
It is a dynamic error to call the key function with two arguments if there is no context node, or if the root of the tree containing the context node is not a document node; or to call the function with three arguments if the root of the tree containing the node supplied in the third argument is not a document node.
If the current function is evaluated within an expression that is evaluated when the context item is absent, a dynamic error occurs.
It is a dynamic error if $node, or the context item if the second argument is omitted, is a node in a tree whose root is not a document node.
It is a dynamic error if $node, or the context item if the second argument is omitted, is a node in a tree whose root is not a document node.
It is a dynamic error if the value supplied as the $property-name argument [to the system-property function] is not a valid QName, or if there is no namespace declaration in scope for the prefix of the QName. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
It is a dynamic error if the $name argument [passed to the function-available function] evaluates to a string that is not a valid EQName, or if the value is a lexical QName with a prefix for which no namespace declaration is present in the static context. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
It is a dynamic error if the arguments supplied to a call on an extension function do not satisfy the rules defined for that particular extension function, or if the extension function raises an error, or if the result of the extension function cannot be converted to an XPath value.
When the containing element is processed with XSLT 1.0 behavior, it is a dynamic error to evaluate an extension function call if no implementation of the extension function is available.
It is a dynamic error if the argument [passed to the type-available function] evaluates to a string that is not a valid EQName, or if the value is a lexical QName with a prefix for which no namespace declaration is present in the static context. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
It is a dynamic error if the argument [passed to the element-available function] evaluates to a string that is not a valid EQName, or if the value is a lexical QName with a prefix for which no namespace declaration is present in the static context. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
When a processor performs fallback for an extension instruction that is not recognized, if the instruction element has one or more xsl:fallback children, then the content of each of the xsl:fallback children must be evaluated; it is a dynamic error if it has no xsl:fallback children.
It is a dynamic error if the effective value of the format attribute [of an xsl:result-document element] is not a valid EQName, or if it does not match the expanded QName of an output definition in the containing package. If the processor is able to detect the error statically (for example, when the format attribute contains no curly brackets), then the processor may optionally raise this as a static error.
It is a dynamic error to evaluate the xsl:result-document instruction in temporary output state.
It is a dynamic error for a transformation to generate two or more final result trees with the same URI.
It is a dynamic error for a stylesheet to write to an external resource and read from the same resource during a single transformation, if the same absolute URI is used to access the resource in both cases.
A dynamic errormay be raised if the input to the processor includes an item that requires availability of an optional feature that the processor does not provide.
It is a dynamic error if there are two xsl:merge-key elements that occupy corresponding positions among the xsl:merge-key children of two different xsl:merge-source elements and that have differing effective values for any of the attributes lang, order, collation, case-order, or data-type. Values are considered to differ if they have different effective values. In the case of the collation attribute, the values are compared as absolute URIs after resolving against the base URI. The error may be raised statically if it is detected statically.
It is a dynamic error if any input sequence to an xsl:merge instruction contains two items that are not correctly sorted according to the merge key values defined on the xsl:merge-key children of the corresponding xsl:merge-source element, when compared using the collation rules defined by the attributes of the corresponding xsl:merge-key children of the xsl:merge instruction, unless the attribute sort-before-merge is present with the value yes.
It is a dynamic error if an invocation of an abstract component is evaluated.
It is a dynamic error if an xsl:global-context-item declaration specifies use="required", and no global context item is supplied. [XSLT 3.0 Erratum E6, bug 30173].
It is a static error if an xsl:function element with no xsl:param children has a streamability attribute with any value other than unclassified.
It is a dynamic error if the target expression [of an xsl:evaluate instruction] is not a valid expression (that is, if a static error occurs when analyzing the string according to the rules of the XPath specification).
It is a dynamic error if an xsl:evaluate instruction is evaluated when use of xsl:evaluate has been statically or dynamically disabled.
It is a dynamic error if the value of the first argument to the accumulator-before or accumulator-after function is a string that is not a valid EQName, or if there is no namespace declaration in scope for the prefix of the QName, or if the name obtained by expanding the QName is not the same as the expanded name of any xsl:accumulator declaration appearing in the package in which the function call appears. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally raise this as a static error.
It is a dynamic error to call the accumulator-before or accumulator-after function when there is no context item.
It is a type error to call the accumulator-before or accumulator-after function when the context item is not a node, or when it is an attribute or namespace node.
It is a dynamic error to call the accumulator-before or accumulator-after function when the context item is a node in a tree to which the selected accumulator is not applicable (including the case where it is not applicable because the document is streamed and the accumulator is not declared with streamable="yes"). Implementations may raise this error but are not required to do so, if they are capable of streaming documents without imposing this restriction.
In the absence of the on-duplicates attribute, a dynamic error occurs if the set of keys in the maps making up the input sequence [of an xsl:map instruction] contains duplicates.
It is an error if there is a cyclic set of dependencies among accumulators such that the (pre- or post-descent) value of an accumulator depends directly or indirectly on itself. A processor may report this as a static error if it can be detected statically. Alternatively a processor may report this as a dynamic error. As a further option, a processor may fail catastrophically when this error occurs.
It is a dynamic error if the current-merge-group function is used when the current merge group is absent. The error may be reported statically if it can be detected statically.
It is a dynamic error if the $source argument of the current-merge-group function (when supplied) does not match the name attribute of any xsl:merge-source element for the current merge operation. The error may be reported statically if it can be detected statically.
It is a dynamic error if the current-merge-key-array or current-merge-key function is used when the current merge key is absent, or when it is invoked in the course of evaluating a pattern. The error may be reported statically if it can be detected statically.
It is a dynamic error if an xsl:try instruction is unable to recover the state of a final result tree because recovery has been disabled by use of the attribute rollback-output="no".
When a transformation is terminated by use of <xsl:message terminate="yes"/>, the effect is the same as when a dynamic error occurs during the transformation. The default error code is XTMM9000; this may be overridden using the error-code attribute of the xsl:message instruction.
When a transformation is terminated by use of xsl:assert, the effect is the same as when a dynamic error occurs during the transformation. The default error code is XTMM9001; this may be overridden using the error-code attribute of the xsl:assert instruction.
Unclassified errors
It is a static error if the names of the fields in an xsl:record-type declaration are not distinct.
It is a static error if an xsl:field element has a default attribute unless it specifies required="no".
This appendix gives the grammar for XSLT patterns. The top-level rule for patterns is Pattern40.
This is an extension of the grammar for XPath expressions. The extended BNF notation is explained at Section A.1.1 NotationXP.
Productions that are identical to their counterparts in XPath 4.0 are suffixed XP and link to the corresponding production in the XPath 4.0 specification. Productions whose names end with P are restrictions of the corresponding XPath production: for example, ArgumentListP is a restricted form of the XPath production ArgumentList.
The following symbols represent portions of terminal symbols; they are not themselves terminal symbols referenced in the grammar.
Digits | ::= | DecDigit ((DecDigit | "_")* DecDigit)? |
| /* ws: explicit */ | ||
DecDigit | ::= | [0-9] |
| /* ws: explicit */ | ||
HexDigits | ::= | HexDigit ((HexDigit | "_")* HexDigit)? |
| /* ws: explicit */ | ||
HexDigit | ::= | [0-9a-fA-F] |
| /* ws: explicit */ | ||
BinaryDigits | ::= | BinaryDigit ((BinaryDigit | "_")* BinaryDigit)? |
| /* ws: explicit */ | ||
BinaryDigit | ::= | [01] |
| /* ws: explicit */ | ||
CommentContents | ::= | (Char+ - (Char* ('(:' | ':)') Char*)) |
| /* ws: explicit */ |
This appendix provides a summary of XSLT language features whose effect is explicitly implementation-defined. The conformance rules (see 2827 Conformance) require vendors to provide documentation that explains how these choices have been exercised.
The implementation-defined features are grouped into categories for convenience.
This category covers interfaces for initiating a transformation, setting its parameters, initializing the static and dynamic context, and collecting the results. In general terms, it is implementation defined how input is passed to the processor and how it returns its output. This includes the interpretation of URIs used to refer to stylesheet packages and modules, source documents and collections, collations, and result documents.
More specifically:
If the initialization of any global variables or parameter depends on the context item, a dynamic error can occur if the context item is absent. It is implementation-defined whether this error occurs during priming of the stylesheet or subsequently when the variable is referenced; and it is implementation-defined whether the error occurs at all if the variable or parameter is never referenced. (See 2.3.2 Priming a Stylesheet)
The way in which an XSLT processor is invoked, and the way in which values are supplied for the source document, starting node, stylesheet parameters, and base output URI, are implementation-defined. (See 2.3.2 Priming a Stylesheet)
The way in which a base output URI is established is implementation-defined (See 2.3.6.2 Serializing the Result)
It is implementation-defined how a package is located given its name and version, and which version of a package is chosen if several are available. (See 3.5.2 Dependencies between Packages)
In the absence of an [xsl:]default-collation attribute, the default collation may be set by the calling application in an implementation-defined way. (See 3.7.2 The default-collation Attribute)
It is implementation-defined what forms of URI reference are acceptable in the href attribute of the xsl:include and xsl:import elements, for example, the URI schemes that may be used, the forms of fragment identifier that may be used, and the media types that are supported. The way in which the URI reference is used to locate a representation of a stylesheet module, and the way in which the stylesheet module is constructed from that representation, are also implementation-defined. (See 3.11.1 Locating Stylesheet Modules)
Implementations may provide user options that relax the requirement for the doc and collection functions (and therefore, by implication, the document function) to return stable results. The manner in which such user options are provided, if at all, is implementation-defined. (See 5.3.3 Initializing the Dynamic Context)
Streamed processing may be initiated by invoking the transformation with an initial mode declared as streamable, while supplying the initial match selection (in an implementation-defined way) as a streamed document. (See 6.7.6 Streamable Templates)
The mechanism by which the caller supplies a value for a stylesheet parameter is implementation-defined. (See 9.5 Global Variables and Parameters)
The detail of any external mechanism allowing a processor to enable or disable checking of assertions is implementation-defined. (See 24.223.2 Assertions)
The way in which the results of the transformation are delivered to an application is implementation-defined. (See 2625 Transformation Results)
It is implementation-defined how the URI appearing in the href attribute of xsl:result-document affects the way in which the result tree is delivered to the application. There may be restrictions on the form of this URI. (See 26.125.1 Creating Secondary Results)
If serialization is supported, then the location to which a final result tree is serialized is implementation-defined, subject to the constraint that relative URI references used to reference one tree from another remain valid. (See 27.226.2 Defaults for serialization parameters)
This category covers extensions and extensibility: mechanisms for providing vendor or user extensions to the language without sacrificing interoperability.
In general terms, it is implementation-defined:
whether and under what circumstances the implementation recognizes any extension functions, extension instructions, extension attributes, user-defined data elements, additional types, additional serialization methods or serialization parameters, or additional collations, and if so, what effect they have.
whether, how, and under what circumstances the implementation allows users to define extension functions, extension instructions, extension attributes, user-defined data elements, additional types, additional serialization methods or serialization parameters, or additional collations. If it does allow users to do so, it must follow the rules given elsewhere in this specification.
what information is available to such extensions (for example, whether they have access to the static and dynamic context.)
where such extensions are allowed, the extent to which the processor enforces their correct behavior (for example, checking that strings returned by extension functions contain only valid XML characters)
More specifically:
The mechanisms for creating new extension instructions and extension functions are implementation-defined. It is not required that implementations provide any such mechanism. (See 2.9 Extensibility)
The set of namespaces that are specially recognized by the implementation (for example, for user-defined data elements, and extension attributes) is implementation-defined. (See 3.7.4 User-defined Data Elements)
The effect of user-defined data elements whose name is in a namespace recognized by the implementation is implementation-defined. (See 3.7.4 User-defined Data Elements)
An implementation may define mechanisms, above and beyond xsl:import-schema, that allow schema components such as type definitions to be made available within a stylesheet. (See 3.14 Built-in Types)
The set of extension functions available in the static context for the target expression of xsl:evaluate is implementation-defined. (See 10.4.1 Static context for the target expression)
If the data-type attribute of the xsl:sort element has a value other than text or number, the effect is implementation-defined. (See 13.1.2 Comparing Sort Key Values)
The posture and sweep of extension functions (and references to extension functions) and extension instructions are implementation-defined. (See 19.8.4.2 Streamability of extension instructions)
Additional streamability categories for stylesheet functions may be defined by an implementation. (See 19.8.5 Classifying Stylesheet Functions)
The effect of an extension function returning a string containing characters that are not permitted in XML is implementation-defined. (See 25.1.224.1.2 Calling Extension Functions)
The way in which external objects are represented in the type system is implementation-defined. (See 25.1.324.1.3 External Objects)
This specification, and the specifications that it refers to, include facilities for adapting the output of a transformation to meet local expectations: examples include the formatting of numbers and dates, and the choice of collations for sorted output. The general principles are:
The specification does not mandate any particular localizations that processors must offer: for example, a conformant processor might choose to provide output in Japanese only.
The specification provides fallback mechanisms so that if a particular localization is requested and is not available, processing does not fail.
More specifically:
The combinations of languages and numbering sequences recognized by the xsl:number instruction, beyond those defined as mandatory in this specification, are implementation-defined. There may be implementation-defined upper bounds on the numbers that can be formatted using any particular numbering sequence. There may be constraints on the values of the ordinal attribute recognized for any given language. (See 12.4 Number to String Conversion Attributes)
The facilities for defining collations and allocating URIs to identify them are largely implementation-defined. (See 13.1.3 Sorting Using Collations)
The algorithm used by xsl:sort to locate a collation, given the values of the lang and case-order attributes, is implementation-defined. (See 13.1.3 Sorting Using Collations)
If none of the collation, lang, or case-order attributes is present (on xsl:sort), the collation is chosen in an implementation-defined way. (See 13.1.3 Sorting Using Collations)
As well as the optional conformance features identified in 2827 Conformance, some specific features of the specification are defined to be optional.
It is implementation-defined whether an XSLT 4.0 processor supports backwards compatible behavior for any XSLT version earlier than XSLT 4.0. (See 3.9 Backwards Compatible Processing)
If an xml:id attribute that has not been subjected to attribute value normalization is copied from a source tree to a result tree, it is implementation-defined whether attribute value normalization will be applied during the copy process. (See 11.9.1 Shallow Copy)
It is implementation-defined whether, and under what circumstances, disabling output escaping is supported. (See 27.526.5 Disabling Output Escaping)
When this specification refers normatively to other specifications, it generally gives implementations freedom to decide (within constraints) which version of the referenced specification should be used. Specifically:
It is implementation-defined which versions and editions of XML and XML Namespaces (1.0 and/or 1.1) are supported. (See 4.1 XML Versions)
It is implementation-defined which versions of XML, HTML, and XHTML are supported in the version attribute of the xsl:output declaration. (See 27.226.2 Defaults for serialization parameters)
It is implementation-defined whether (and if so how) an XSLT 3.0 processor is able to work with versions of XPath[XSLT and XQuery Serialization] later than XPath 3.1. (See 28 Conformance27.3 Serialization Feature)
It is implementation-defined whether (and if so how) an XSLT 3.0 processor is able to work with versions of [XSLT and XQuery Serialization] later than 3.1. (See 28.3 Serialization Feature)
To accommodate variations in the way that the XSLT language is deployed, and the constraints of different processing environments, defaults for some options are implementation-defined. In addition, limits on the sizes of ranges of values permitted are in general implementation-defined:
Limits on the value space of primitive datatypes, where not fixed by [XML Schema Part 2], are implementation-defined. (See 4.6 Limits)
The default value of the encoding attribute of the xsl:output element is implementation-defined. Where the encoding is UTF-8, the default for the byte-order-mark attribute is implementation-defined. (See 27.226.2 Defaults for serialization parameters)
Some aspects of error handling are implementation-defined:
It is implementation-defined whether type errors are raised statically. (See 2.14 Error Handling)
If the effective version of any element in the stylesheet is not 1.0 or 2.0 but is less than 4.0, the recommended action is to raise a static error; however, processors may recognize such values and process the element in an implementation-defined way. (See 3.9 Backwards Compatible Processing)
The default values for the warning-on-no-match and warning-on-multiple-match attributes of xsl:mode are implementation-defined. (See 6.7.1 Declaring Modes)
The form of any warnings output when there is no matching template rule, or when there are multiple matching template rules, is implementation-defined. (See 6.7.1 Declaring Modes)
The destination and formatting of messages written using the xsl:message instruction are implementation-defined. (See 24.123.1 Messages)
The functions available for use within an XSLT stylesheet can be classified based firstly, on where the function is defined, and secondly, on where it can be used. Specifically, the set of functions available is slightly different for :
Regular XPath expressions within the stylesheet, for example those appearing in select or test attributes, or between braces in a text value template (R)
XPath expressions evaluated dynamically using xsl:evaluate (D)
The categories are listed in the following table:
| Category | Defined where? | Available where? | Notes |
|---|---|---|---|
| User-defined functions | Defined using xsl:function declarations in the stylesheet | R, D | Functions are private by default; private functions can be referenced only within the package where they are declared (and not in xsl:evaluate expressions). |
| Constructor functions for built-in types | Section 20 Constructor functionsFO | R, S, D | These functions are all in the namespace conventionally associated with the prefix xs. The semantics of a constructor function are identical to the semantics of a cast expression. |
| Constructor functions for user-defined types | Section 20 Constructor functionsFO | R, D (if schema-aware="yes") | This category includes a function for every named user-defined simple type in an imported schema; the function allows the conversion of strings and certain other values to instances of the user-defined type. |
| Functions defined in XPath 4.0 | [Functions and Operators 4.0] | R, S, D | Includes functions in the namespaces conventionally referred to be the prefixes fn and math. |
| Functions defined in XSLT 4.0 | This specification | R, S (see note), D | See HG.2 List of XSLT-defined functions. There is an overlap with the set of functions defined in XPath 4.0. The functions available in static expressions are: element-available, function-available, type-available, available-system-properties, and system-property. |
| Extension functions | Implementation-defined: see 25.124.1 Extension Functions. | R, S, D | Availability is implementation-defined |
This appendix acts as an index of functions defined in this specification, to augment the set of functions defined in [Functions and Operators 4.0].
accumulator-afteraccumulator-beforeavailable-system-propertiescharacter-mapcopy-ofcurrentcurrent-groupcurrent-grouping-keycurrent-merge-groupcurrent-merge-keycurrent-merge-key-arraycurrent-output-uridocumentelement-availablefunction-availablekeymap-for-keyregex-groupsnapshotstream-availablesystem-propertytype-availableunparsed-entity-public-idunparsed-entity-uriFor convenience, schemas are provided for validation of XSLT 4.0 stylesheets using the XSD 1.1 and Relax NG schema languages. These are non-normative. Neither will detect every static error that might arise in an XSLT 4.0 stylesheet (for example, there is no attempt to check the syntax of XPath expressions); in addition, these schemas may reject some stylesheets that are valid, for example because they rely on xsl:use-when to eliminate sections of code that would otherwise be invalid.
The following XSD 1.1 schema describes the structure of an XSLT stylesheet module. There are some limitations:
It does not define all the constraints that apply to a stylesheet (for example, it does not attempt to define a datatype that precisely represents attributes containing XPath expressions).
Stylesheets that use forwards compatible behavior (an [xsl:]version attribute greater than 4.0), or that have sections excluded using [xsl:]use-when attributes, are not required to conform to the schema.
The specification allows xsl:note elements to appear anywhere, but this schema is more restrictive.
A copy of this schema is available at schema-for-xslt40.xsd
Note:
The schema as written uses a lax wildcard to permit literal result elements to appear in a sequence constructor. This assumes that the schema used for validation will not contain any global element declaration that matches the element name of a literal result element. The content model for an element such as invoice appearing within a stylesheet is not the same as the content model for the same element appearing within a source document (it is likely to contain XSLT instructions rather than other elements from the target vocabulary): therefore, including such declarations in the schema used for validating a stylesheet is inappropriate.
The reason that lax validation rather than skip validation is used is so that XSLT instructions appearing as children of the literal result element will themselves be validated, using the appropriate global element declaration.
Note:
The schema uses XSD 1.1 assertions to represent some of the non-grammatical constraints appearing in the specification, for example the rule that some elements can have either a select attribute or a contained sequence constructor, but not both. At this stage, no attempt has been made to represent every such constraint, even where it is not difficult to express the rule. There will always be some constraints that cannot be expressed at all, for example those that require access to multiple stylesheet modules, those that require access to the in-scope schema components, and those that involve parsing a non-regular grammar, such as the grammar for patterns.
Apart from assertions, the only other significant use of XSD 1.1 features is that the elements xsl:param and xsl:variable are in two substitution groups: one containing all instructions, and one containing all declarations. If the schema needs to be converted to an XSD 1.0 schema, removing all assertions is straightforward; the other change needed is to remove xsl:param and xsl:variable from the substitution group for declarations, and instead permit them explicitly as children of xsl:transform.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
targetNamespace="http://www.w3.org/1999/XSL/Transform"
elementFormDefault="qualified"
vc:minVersion="1.1">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation>
<p>
This is an XSD 1.1 schema for XSLT 4.0 stylesheets. It defines all the
elements that appear in the XSLT namespace; it also provides hooks that
allow the inclusion of user-defined literal result elements, extension
instructions, and top-level data elements.
</p>
<p>
This schema is available for use under the conditions of the W3C Software
License published at
http://www.w3.org/Consortium/Legal/copyright-software-19980720
</p>
<p>
The schema is organized as follows:
</p>
<ul>
<li>
PART A: definitions of complex types and model groups used as the basis
for element definitions
</li>
<li>
PART B: definitions of individual XSLT elements
</li>
<li>
PART C: definitions for literal result elements
</li>
<li>
PART D: definitions of simple types used in attribute definitions
</li>
</ul>
<p>
The schema has a number of limitations:
</p>
<ul>
<li>
The XSLT specification allows additional elements and attributes to be
present where forwards compatibility is invoked. This schema does not.
</li>
<li>
The XSLT specification allows arbitrary content in a part of the
stylesheet that is excluded by virtue of a use-when attribute. This
schema does not.
</li>
<li>
The handling of literal result elements in this schema is imperfect;
although various options are allowed, none matches the specification
exactly. For example, the content of a literal result element uses lax
validation, which permits child elements in the XSLT namespace that have
no declaration in this schema.
</li>
<li>
The schema makes no attempt to check XPath expressions for syntactic or
semantic correctness, nor to check that component references are
resolved (for example that a template named in <code>xsl:call-template</code> has a
declaration). Doing this in general requires cross-document validation,
which is beyond the scope of XSD.
</li>
<li>
The XSLT specification allows <code>xsl:note</code> elements to appear
anywhere, with arbitrary content. This schema does not: for example, it does
not allow <code>xsl:note</code> as a child of an element such as <code>xsl:text</code>
or <code>xsl:strip-space</code>.
</li>
<li>
The schema imports the schema for XSD 1.0 schema documents. In
stylesheets that contain an inline XSD 1.1 schema, this import should be
replaced with one for the schema for XSD 1.1 schema documents.
</li>
</ul>
</xs:documentation>
</xs:annotation>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!--
The declaration of xml:space and xml:lang may need to be commented out because
of problems processing the schema using various tools
-->
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
<!--schemaLocation="http://www.w3.org/2001/xml.xsd"-->
<!--
An XSLT stylesheet may contain an in-line schema within an xsl:import-schema element,
so the Schema for schemas needs to be imported. We use the XSD 1.1 version.
-->
<xs:import namespace="http://www.w3.org/2001/XMLSchema"
schemaLocation="http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation>
<p>
PART A: definitions of complex types and model groups used as the basis
for element definitions
</p>
</xs:documentation>
</xs:annotation>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:defaultOpenContent>
<!-- Allow xsl:note anywhere -->
<xs:any processContents="strict"
namespace="##targetNamespace"
notQName="xsl:accept
xsl:accumulator
xsl:accumulator-rule
xsl:analyze-string
xsl:apply-imports
xsl:apply-templates
xsl:array
xsl:assert
xsl:attribute
xsl:attribute-set
xsl:break
xsl:call-template
xsl:catch
xsl:character-map
xsl:choose
xsl:comment
xsl:context-item
xsl:copy
xsl:copy-of
xsl:document
xsl:decimal-format
xsl:element
xsl:evaluate
xsl:expose
xsl:fallback
xsl:for-each
xsl:for-each-group
xsl:fork
xsl:function
xsl:global-context-item
xsl:if
xsl:import
xsl:import-schema
xsl:include
xsl:iterate
xsl:key
xsl:map
xsl:map-entry
xsl:matching-substring
xsl:merge
xsl:merge-action
xsl:merge-key
xsl:merge-source
xsl:message
xsl:mode
xsl:namespace
xsl:namespace-alias
xsl:next-iteration
xsl:next-match
xsl:non-matching-substring
xsl:number
xsl:on-completion
xsl:on-empty
xsl:on-non-empty
xsl:otherwise
xsl:output
xsl:output-character
xsl:override
xsl:package
xsl:param
xsl:perform-sort
xsl:preserve-space
xsl:processing-instruction
xsl:result-document
xsl:sequence
xsl:sort
xsl:source-document
xsl:strip-space
xsl:stylesheet
xsl:switch
xsl:template
xsl:text
xsl:transform
xsl:try
xsl:use-package
xsl:value-of
xsl:variable
xsl:when
xsl:where-populated
xsl:with-param
"/>
</xs:defaultOpenContent>
<xs:complexType name="generic-element-type" mixed="true">
<xs:annotation>
<xs:documentation>
<p>
This complex type provides a generic supertype for all XSLT elements; it
contains the definitions of the standard attributes that may appear on
any element.
</p>
</xs:documentation>
</xs:annotation>
<xs:attribute name="default-collation" type="xsl:uri-list"/>
<xs:attribute name="default-mode" type="xsl:default-mode-type"/>
<xs:attribute name="default-validation"
type="xsl:validation-strip-or-preserve"
default="strip"/>
<xs:attribute name="exclude-result-prefixes" type="xsl:prefix-list-or-all"/>
<xs:attribute name="expand-text" type="xsl:yes-or-no"/>
<xs:attribute name="extension-element-prefixes" type="xsl:prefix-list"/>
<xs:attribute name="use-when" type="xsl:expression"/>
<xs:attribute name="xpath-default-namespace" type="xs:anyURI"/>
<xs:attribute name="_default-collation" type="xs:string"/>
<xs:attribute name="_default-mode" type="xs:string"/>
<xs:attribute name="_default-validation" type="xs:string"/>
<xs:attribute name="_exclude-result-prefixes" type="xs:string"/>
<xs:attribute name="_expand-text" type="xs:string"/>
<xs:attribute name="_extension-element-prefixes" type="xs:string"/>
<xs:attribute name="_use-when" type="xs:string"/>
<xs:attribute name="_xpath-default-namespace" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<xs:complexType name="versioned-element-type" mixed="true">
<xs:annotation>
<xs:documentation>
<p>This complex type provides a generic supertype for all XSLT elements with
the exception of <code>xsl:output</code>; it contains the
definitions of the <code>version</code> attribute that may appear on any element.
</p>
<p>The <code>xsl:output</code> element does not use this definition because, although it
has a <code>version</code> attribute, the syntax and semantics of this attribute are
unrelated to the standard <code>version</code> attribute allowed on other elements.</p>
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="xsl:generic-element-type">
<xs:attribute name="version" type="xs:decimal" use="optional"/>
<xs:attribute name="_version" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="element-only-versioned-element-type" mixed="false">
<xs:complexContent>
<xs:restriction base="xsl:versioned-element-type">
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="sequence-constructor">
<xs:annotation>
<xs:documentation>
<p>
This complex type provides a generic supertype for all XSLT elements
that allow a sequence constructor as their content.
</p>
</xs:documentation>
</xs:annotation>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="sequence-constructor-and-select">
<xs:annotation>
<xs:documentation>
<p>
This complex type allows a sequence constructor and a select attribute.
</p>
</xs:documentation>
</xs:annotation>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="_select" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="sequence-constructor-or-select">
<xs:annotation>
<xs:documentation>
<p>
This complex type allows a sequence constructor or a select attribute,
but not both.
</p>
</xs:documentation>
</xs:annotation>
<xs:complexContent mixed="true">
<xs:restriction base="xsl:sequence-constructor-and-select">
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
<xs:assert test="not(exists(@select | @_select) and
(exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:group name="sequence-constructor-group">
<xs:annotation>
<xs:documentation>
<p>
This complex type provides a generic supertype for all XSLT elements
that allow a sequence constructor as their content.
</p>
</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element ref="xsl:instruction"/>
<xs:group ref="xsl:result-elements"/>
</xs:choice>
</xs:group>
<xs:element name="declaration" type="xsl:generic-element-type" abstract="true"/>
<xs:element name="instruction" type="xsl:versioned-element-type" abstract="true"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation>
<p>
PART B: definitions of individual XSLT elements Elements are listed in
alphabetical order.
</p>
</xs:documentation>
</xs:annotation>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="accept">
<xs:annotation>
<xs:documentation>
<p>This element appears as a child of <code>xsl:use-package</code> and defines
any variations that the containing package wishes to make to the visibility of
components made available from a library package. For example, it may indicate that
some of the public components in the library package are not to be made available
to the containing package.</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="component" type="xsl:component-kind-type"/>
<xs:attribute name="names" type="xsl:component-tests"/>
<xs:attribute name="visibility" type="xsl:visibility-type"/>
<xs:attribute name="_component" type="xs:string"/>
<xs:attribute name="_names" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
<xs:assert test="exists(@component | @_component)"/>
<xs:assert test="exists(@names | @_names)"/>
<xs:assert test="exists(@visibility | @_visibility)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="accumulator" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:accumulator-rule" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="initial-value" type="xsl:expression"/>
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="streamable" type="xsl:yes-or-no"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_initial-value" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_streamable" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="accumulator-rule">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:sequence/>
<xs:attribute name="match" type="xsl:pattern"/>
<xs:attribute name="phase">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="start"/>
<xs:enumeration value="end"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="capture" type="xsl:yes-or-no" default="no"/>
<xs:attribute name="_match" type="xs:string"/>
<xs:attribute name="_phase" type="xs:string"/>
<xs:attribute name="_capture" type="xs:string"/>
<xs:assert test="exists(@match | @_match)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="analyze-string" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:matching-substring" minOccurs="0"/>
<xs:element ref="xsl:non-matching-substring" minOccurs="0"/>
<xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="regex" type="xsl:avt"/>
<xs:attribute name="flags" type="xsl:avt" default=""/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_regex" type="xs:string"/>
<xs:attribute name="_flags" type="xs:string"/>
<xs:assert test="exists(@select | @_select)"/>
<xs:assert test="exists(@regex | @_regex)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="apply-imports" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="apply-templates" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:sort"/>
<xs:element ref="xsl:with-param"/>
</xs:choice>
<xs:attribute name="select" type="xsl:expression" default="child::node()"/>
<xs:attribute name="separator" type="xsl:avt"/>
<xs:attribute name="mode" type="xsl:mode"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_separator" type="xs:string"/>
<xs:attribute name="_mode" type="xs:string"/>
<xs:assert test="every $e in subsequence(xsl:sort, 2)
satisfies empty($e/(@stable | @_stable))">
<xs:annotation>
<xs:documentation>
<p>
It is a static error if an <code>xsl:sort</code> element other than the first
in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
attribute.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="array"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="array-member"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="assert" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="test" type="xsl:expression"/>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="error-code" type="xsl:avt"/>
<xs:attribute name="_test" type="xs:string"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_error-code" type="xs:string"/>
<xs:assert test="exists(@test | @_test)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="attribute" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="name" type="xsl:avt"/>
<xs:attribute name="namespace" type="xsl:avt"/>
<xs:attribute name="separator" type="xsl:avt"/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_namespace" type="xs:string"/>
<xs:attribute name="_separator" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="attribute-set" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:attribute"/>
</xs:sequence>
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="streamable" type="xsl:yes-or-no"/>
<xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
<xs:attribute name="visibility" type="xsl:visibility-type"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_streamable" type="xs:string"/>
<xs:attribute name="_use-attribute-sets" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="break"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="call-template" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="catch">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="errors" type="xs:token" use="optional"/>
<xs:attribute name="_errors" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="character-map" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:output-character" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="use-character-maps" type="xsl:EQNames" default=""/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_use-character-maps" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="choose" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:when" maxOccurs="unbounded"/>
<xs:element ref="xsl:otherwise" minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="comment"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="context-item">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="as" type="xsl:item-type"/>
<xs:attribute name="use">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="required"/>
<xs:enumeration value="optional"/>
<xs:enumeration value="absent"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_use" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="copy" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
<xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/>
<xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_copy-namespaces" type="xs:string"/>
<xs:attribute name="_inherit-namespaces" type="xs:string"/>
<xs:attribute name="_use-attribute-sets" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="copy-of" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="copy-accumulators" type="xsl:yes-or-no" default="no"/>
<xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_copy-accumulators" type="xs:string"/>
<xs:attribute name="_copy-namespaces" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="exists(@select | @_select)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="document" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="decimal-format" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="decimal-separator" type="xsl:char-optionally-expanded" default="."/>
<xs:attribute name="grouping-separator" type="xsl:char-optionally-expanded" default=","/>
<xs:attribute name="infinity" type="xs:string" default="Infinity"/>
<xs:attribute name="minus-sign" type="xs:string" default="-"/>
<xs:attribute name="exponent-separator" type="xsl:char-optionally-expanded" default="e"/>
<xs:attribute name="NaN" type="xs:string" default="NaN"/>
<xs:attribute name="percent" type="xsl:char-optionally-expanded" default="%"/>
<xs:attribute name="per-mille" type="xsl:char-optionally-expanded" default="~"/>
<xs:attribute name="zero-digit" type="xsl:zero-digit" default="0"/>
<xs:attribute name="digit" type="xsl:char" default="#"/>
<xs:attribute name="pattern-separator" type="xsl:char" default=";"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_decimal-separator" type="xs:string"/>
<xs:attribute name="_grouping-separator" type="xs:string"/>
<xs:attribute name="_infinity" type="xs:string"/>
<xs:attribute name="_minus-sign" type="xs:string"/>
<xs:attribute name="_exponent-separator" type="xs:string"/>
<xs:attribute name="_NaN" type="xs:string"/>
<xs:attribute name="_percent" type="xs:string"/>
<xs:attribute name="_per-mille" type="xs:string"/>
<xs:attribute name="_zero-digit" type="xs:string"/>
<xs:attribute name="_digit" type="xs:string"/>
<xs:attribute name="_pattern-separator" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="element" substitutionGroup="xsl:instruction">
<xs:complexType mixed="true">
<xs:complexContent>
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="name" type="xsl:avt"/>
<xs:attribute name="namespace" type="xsl:avt"/>
<xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/>
<xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_namespace" type="xs:string"/>
<xs:attribute name="_inherit-namespaces" type="xs:string"/>
<xs:attribute name="_use-attribute-sets" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="evaluate" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:with-param"/>
<xs:element ref="xsl:fallback"/>
</xs:choice>
<xs:attribute name="xpath" type="xsl:expression"/>
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="base-uri" type="xsl:avt"/>
<xs:attribute name="context-item" type="xsl:expression"/>
<xs:attribute name="namespace-context" type="xsl:expression"/>
<xs:attribute name="schema-aware" type="xsl:avt"/>
<xs:attribute name="with-params" type="xsl:expression"/>
<xs:attribute name="_xpath" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_base-uri" type="xs:string"/>
<xs:attribute name="_context-item" type="xs:string"/>
<xs:attribute name="_namespace-context" type="xs:string"/>
<xs:attribute name="_schema-aware" type="xs:string"/>
<xs:attribute name="_with-params" type="xs:string"/>
<xs:assert test="exists(@xpath | @_xpath)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="expose">
<xs:annotation>
<xs:documentation>
<p>This element appears as a child of <code>xsl:use-package</code> and defines
the visibility of components that are made available (or not) by this package
to other using packages.</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="component" type="xsl:component-kind-type"/>
<xs:attribute name="names" type="xsl:component-tests"/>
<xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
<xs:attribute name="_component" type="xs:string"/>
<xs:attribute name="_names" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="fallback"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor"/>
<xs:element name="for-each" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="separator" type="xsl:avt"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_separator" type="xs:string"/>
<xs:assert test="every $e in subsequence(xsl:sort, 2)
satisfies empty($e/(@stable | @_stable))">
<xs:annotation>
<xs:documentation>
<p>
It is a static error if an <code>xsl:sort</code> element other than the first
in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
attribute.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="exists(@select | @_select)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="for-each-group" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="group-by" type="xsl:expression"/>
<xs:attribute name="group-adjacent" type="xsl:expression"/>
<xs:attribute name="group-starting-with" type="xsl:pattern"/>
<xs:attribute name="group-ending-with" type="xsl:pattern"/>
<xs:attribute name="split-when" type="xsl:expression"/>
<xs:attribute name="composite" type="xsl:yes-or-no"/>
<xs:attribute name="collation" type="xsl:avt"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_group-by" type="xs:string"/>
<xs:attribute name="_group-adjacent" type="xs:string"/>
<xs:attribute name="_group-starting-with" type="xs:string"/>
<xs:attribute name="_group-ending-with" type="xs:string"/>
<xs:attribute name="_split_when" type="xs:string"/>
<xs:attribute name="_composite" type="xs:string"/>
<xs:attribute name="_collation" type="xs:string"/>
<xs:assert test="exists(@select | @_select)"/>
<xs:assert test="every $e in subsequence(xsl:sort, 2)
satisfies empty($e/(@stable | @_stable))">
<xs:annotation>
<xs:documentation>
<p>
It is a static error if an <code>xsl:sort</code> element other than the first
in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
attribute.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="count(((@group-by|@_group-by)[1],
(@group-adjacent|@_group-adjacent)[1],
(@group-starting-with|@_group-starting-with)[1],
(@group-ending-with|@_group-ending-with)[1],
(@split-when|@_split-when)[1])) = 1">
<xs:annotation>
<xs:documentation>
<p>
These four attributes are mutually exclusive: it is a static
error if none of these four attributes is present or if more
than one of them is present.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (exists(@collation|@_collation) or exists(@composite|@_composite))
then (exists(@group-by|@_group-by) or exists(@group-adjacent|@_group-adjacent))
else true()">
<xs:annotation>
<xs:documentation>
<p>
It is an error to specify the collation attribute or the
composite attribute if neither the group-by attribute nor
group-adjacent attribute is specified.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="fork" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:sequence"/>
<xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:sequence>
<xs:element ref="xsl:for-each-group"/>
<xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:choice>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="function" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xsl:EQName-in-namespace"/>
<xs:attribute name="override" type="xsl:yes-or-no" default="yes"/>
<xs:attribute name="as" type="xsl:sequence-type" default="item()*"/>
<xs:attribute name="visibility" type="xsl:visibility-type"/>
<xs:attribute name="streamability" type="xsl:streamability-type"/>
<xs:attribute name="override-extension-function" type="xsl:yes-or-no"/>
<xs:attribute name="new-each-time" type="xsl:yes-or-no-or-maybe"/>
<xs:attribute name="cache" type="xsl:yes-or-no"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_override" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
<xs:attribute name="_streamability" type="xs:string"/>
<xs:attribute name="_override-extension-function" type="xs:string"/>
<xs:attribute name="_new-each-time" type="xs:string"/>
<xs:attribute name="_cache" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
<xs:assert test="every $e in xsl:param satisfies empty($e/(@visibility | @_visibility))">
<xs:annotation>
<xs:documentation>
<p>A parameter for a function must have no <code>visibility</code> attribute.</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="global-context-item" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="as" type="xsl:item-type"/>
<xs:attribute name="use">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="required"/>
<xs:enumeration value="optional"/>
<xs:enumeration value="absent"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_use" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="if" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="test" type="xsl:expression"/>
<xs:attribute name="then" type="xsl:expression"/>
<xs:attribute name="else" type="xsl:expression"/>
<xs:attribute name="_test" type="xs:string"/>
<xs:attribute name="_then" type="xs:string"/>
<xs:attribute name="_else" type="xs:string"/>
<xs:assert test="exists(@test | @_test)"/>
<xs:assert test="not(exists(@then | @_then) and
(exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="import" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attribute name="_href" type="xs:string"/>
<xs:assert test="exists(@href | @_href)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="import-schema" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xs:schema" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="namespace" type="xs:anyURI"/>
<xs:attribute name="schema-location" type="xs:anyURI"/>
<xs:attribute name="_namespace" type="xs:string"/>
<xs:attribute name="_schema-location" type="xs:string"/>
<xs:assert test="not(exists(@schema-location | @_schema-location) and exists(xs:schema))">
<xs:annotation>
<xs:documentation>
<p>
XTSE0215: It is a static error if an <code>xsl:import-schema</code> element
that contains an xs:schema element has a <code>schema-location</code>
attribute
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="include" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attribute name="_href" type="xs:string"/>
<xs:assert test="exists(@href | @_href)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="iterate" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="xsl:on-completion" minOccurs="0" maxOccurs="1"/>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:assert test="exists(@select | @_select)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="key" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="match" type="xsl:pattern"/>
<xs:attribute name="use" type="xsl:expression"/>
<xs:attribute name="composite" type="xsl:yes-or-no"/>
<xs:attribute name="collation" type="xs:anyURI"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_match" type="xs:string"/>
<xs:attribute name="_use" type="xs:string"/>
<xs:attribute name="_composite" type="xs:string"/>
<xs:attribute name="_collation" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
<xs:assert test="exists(@match | @_match)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="map"
substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="on-duplicates" type="xsl:expression"/>
<xs:attribute name="ordering" type="xsl:avt"/>
<xs:attribute name="_on-duplicates" type="xs:string"/>
<xs:attribute name="_ordering" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="map-entry" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-and-select">
<xs:attribute name="key" type="xsl:expression"/>
<xs:attribute name="_key" type="xs:string"/>
<xs:assert test="exists(@key | @_key)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="matching-substring" type="xsl:sequence-constructor-or-select"/>
<xs:element name="merge" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:merge-source" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="xsl:merge-action" minOccurs="1" maxOccurs="1"/>
<xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="merge-action" type="xsl:sequence-constructor"/>
<xs:element name="merge-key" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="lang" type="xsl:avt"/>
<xs:attribute name="order" type="xsl:avt"/>
<xs:attribute name="collation" type="xs:anyURI"/>
<xs:attribute name="case-order" type="xsl:avt"/>
<xs:attribute name="data-type" type="xsl:avt"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_lang" type="xs:string"/>
<xs:attribute name="_order" type="xs:string"/>
<xs:attribute name="_collation" type="xs:string"/>
<xs:attribute name="_case-order" type="xs:string"/>
<xs:attribute name="_data-type" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="merge-source">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:merge-key" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName"/>
<xs:attribute name="for-each-item" type="xsl:expression"/>
<xs:attribute name="for-each-source" type="xsl:expression"/>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="streamable" type="xsl:yes-or-no"/>
<xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
<xs:attribute name="sort-before-merge" type="xsl:yes-or-no"/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_for-each-item" type="xs:string"/>
<xs:attribute name="_for-each-source" type="xs:string"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_streamable" type="xs:string"/>
<xs:attribute name="_use-accumulators" type="xs:string"/>
<xs:attribute name="_sort-before-merge" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="exists(@select | @_select)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="message" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="terminate" type="xsl:avt" default="no"/>
<xs:attribute name="error-code" type="xsl:avt"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_terminate" type="xs:string"/>
<xs:attribute name="_error-code" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="mode" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent mixed="false">
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:template"/>
<xs:element ref="xsl:fallback"/>
</xs:choice>
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="streamable" type="xsl:yes-or-no" default="no"/>
<xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
<xs:attribute name="on-no-match" type="xsl:on-no-match-type" default="shallow-skip"/>
<xs:attribute name="on-multiple-match"
type="xsl:on-multiple-match-type"
default="use-last"/>
<xs:attribute name="warning-on-no-match" type="xsl:yes-or-no"/>
<xs:attribute name="warning-on-multiple-match" type="xsl:yes-or-no"/>
<xs:attribute name="typed" type="xsl:typed-type"/>
<xs:attribute name="visibility">
<xs:simpleType>
<xs:restriction base="xsl:visibility-type">
<xs:enumeration value="public"/>
<xs:enumeration value="private"/>
<xs:enumeration value="final"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_streamable" type="xs:string"/>
<xs:attribute name="_use-accumulators" type="xs:string"/>
<xs:attribute name="_on-no-match" type="xs:string"/>
<xs:attribute name="_on-multiple-match" type="xs:string"/>
<xs:attribute name="_warning-on-no-match" type="xs:string"/>
<xs:attribute name="_warning-on-multiple-match" type="xs:string"/>
<xs:attribute name="_typed" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="namespace" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="name" type="xsl:avt"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="namespace-alias" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="stylesheet-prefix" type="xsl:prefix-or-default"/>
<xs:attribute name="result-prefix" type="xsl:prefix-or-default"/>
<xs:attribute name="_stylesheet-prefix" type="xs:string"/>
<xs:attribute name="_result-prefix" type="xs:string"/>
<xs:assert test="exists(@stylesheet-prefix | @_stylesheet-prefix)"/>
<xs:assert test="exists(@result-prefix | @_result-prefix)"/>
<xs:assert test="every $prefix in (@stylesheet-prefix, @result-prefix)/normalize-space(.)[. ne '#default']
satisfies $prefix = in-scope-prefixes(.)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="next-iteration" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="next-match" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:with-param"/>
<xs:element ref="xsl:fallback"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="non-matching-substring" type="xsl:sequence-constructor-or-select"/>
<xs:element name="note" type="xs:anyType"/>
<xs:element name="number" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:attribute name="value" type="xsl:expression"/>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="level" type="xsl:level" default="single"/>
<xs:attribute name="count" type="xsl:pattern"/>
<xs:attribute name="from" type="xsl:pattern"/>
<xs:attribute name="format" type="xsl:avt" default="1"/>
<xs:attribute name="lang" type="xsl:avt"/>
<xs:attribute name="letter-value" type="xsl:avt"/>
<xs:attribute name="ordinal" type="xsl:avt"/>
<xs:attribute name="start-at" type="xsl:avt"/>
<xs:attribute name="grouping-separator" type="xsl:avt"/>
<xs:attribute name="grouping-size" type="xsl:avt"/>
<xs:attribute name="_value" type="xs:string"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_level" type="xs:string"/>
<xs:attribute name="_count" type="xs:string"/>
<xs:attribute name="_from" type="xs:string"/>
<xs:attribute name="_format" type="xs:string"/>
<xs:attribute name="_lang" type="xs:string"/>
<xs:attribute name="_letter-value" type="xs:string"/>
<xs:attribute name="_ordinal" type="xs:string"/>
<xs:attribute name="_start-at" type="xs:string"/>
<xs:attribute name="_grouping-separator" type="xs:string"/>
<xs:attribute name="_grouping-size" type="xs:string"/>
<xs:assert test="if (exists(@value | @_value))
then empty((@select | @_select, @count | @_count, @from | @_from))
and (exists(@_level) or normalize-space(@level)='single')
else true()">
<xs:annotation>
<xs:documentation>
<p>
It is a static error if the value attribute of <code>xsl:number</code> is
present unless the <code>select</code>, <code>level</code>, <code>count</code>,
and <code>from</code> attributes are all absent.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="on-completion" type="xsl:sequence-constructor-or-select"/>
<xs:element name="on-empty"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="on-non-empty"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="otherwise"
type="xsl:sequence-constructor-or-select"/>
<xs:element name="output" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:generic-element-type">
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="method" type="xsl:method"/>
<xs:attribute name="allow-duplicate-names" type="xsl:yes-or-no"/>
<xs:attribute name="build-tree" type="xsl:yes-or-no"/>
<xs:attribute name="byte-order-mark" type="xsl:yes-or-no"/>
<xs:attribute name="cdata-section-elements" type="xsl:EQNames"/>
<xs:attribute name="doctype-public" type="xs:string"/>
<xs:attribute name="doctype-system" type="xs:string"/>
<xs:attribute name="encoding" type="xs:string"/>
<xs:attribute name="escape-solidus" type="xsl:yes-or-no"/>
<xs:attribute name="escape-uri-attributes" type="xsl:yes-or-no"/>
<xs:attribute name="html-version" type="xs:decimal"/>
<xs:attribute name="include-content-type" type="xsl:yes-or-no"/>
<xs:attribute name="indent" type="xsl:yes-or-no"/>
<xs:attribute name="item-separator" type="xs:string"/>
<xs:attribute name="json-lines" type="xsl:yes-or-no"/>
<xs:attribute name="json-node-output-method" type="xsl:method"/>
<xs:attribute name="media-type" type="xs:string"/>
<xs:attribute name="normalization-form" type="xs:NMTOKEN"/>
<xs:attribute name="omit-xml-declaration" type="xsl:yes-or-no"/>
<xs:attribute name="parameter-document" type="xs:anyURI"/>
<xs:attribute name="standalone" type="xsl:yes-or-no-or-omit"/>
<xs:attribute name="suppress-indentation" type="xsl:EQNames"/>
<xs:attribute name="undeclare-prefixes" type="xsl:yes-or-no"/>
<xs:attribute name="use-character-maps" type="xsl:EQNames"/>
<xs:attribute name="version" type="xs:NMTOKEN"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_method" type="xs:string"/>
<xs:attribute name="_byte-order-mark" type="xs:string"/>
<xs:attribute name="_cdata-section-elements" type="xs:string"/>
<xs:attribute name="_doctype-public" type="xs:string"/>
<xs:attribute name="_doctype-system" type="xs:string"/>
<xs:attribute name="_encoding" type="xs:string"/>
<xs:attribute name="_escape-solidus" type="xs:string"/>
<xs:attribute name="_escape-uri-attributes" type="xs:string"/>
<xs:attribute name="_html-version" type="xs:string"/>
<xs:attribute name="_include-content-type" type="xs:string"/>
<xs:attribute name="_indent" type="xs:string"/>
<xs:attribute name="_item-separator" type="xs:string"/>
<xs:attribute name="_media-type" type="xs:string"/>
<xs:attribute name="_normalization-form" type="xs:string"/>
<xs:attribute name="_omit-xml-declaration" type="xs:string"/>
<xs:attribute name="_parameter-document" type="xs:string"/>
<xs:attribute name="_standalone" type="xs:string"/>
<xs:attribute name="_suppress-indentation" type="xs:string"/>
<xs:attribute name="_undeclare-prefixes" type="xs:string"/>
<xs:attribute name="_use-character-maps" type="xs:string"/>
<xs:attribute name="_version" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="output-character">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="character" type="xsl:char"/>
<xs:attribute name="string" type="xs:string"/>
<xs:attribute name="_character" type="xs:string"/>
<xs:attribute name="_string" type="xs:string"/>
<xs:assert test="exists(@character | @_character)"/>
<xs:assert test="exists(@string | @_string)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="override">
<xs:annotation>
<xs:documentation>
<p>This element appears as a child of <code>xsl:use-package</code> and defines
any overriding definitions of components that the containing package wishes to make
to the components made available from a library package.</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:template"/>
<xs:element ref="xsl:function"/>
<xs:element ref="xsl:variable"/>
<xs:element ref="xsl:param"/>
<xs:element ref="xsl:attribute-set"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="package">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:expose"/>
<xs:element ref="xsl:declaration"/>
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="declared-modes" type="xsl:yes-or-no"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="name" type="xs:anyURI"/>
<xs:attribute name="package-version" type="xs:string"/>
<xs:attribute name="input-type-annotations" type="xsl:input-type-annotations-type"/>
<xs:attribute name="fixed-namespaces" type="xsl:fixed-namespaces-type"/>
<xs:attribute name="_declared-modes" type="xs:string"/>
<xs:attribute name="_id" type="xs:string"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_package-version" type="xs:string"/>
<xs:attribute name="_input-type-annotations" type="xs:string"/>
<xs:attribute name="_fixed-namespaces" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="param" substitutionGroup="xsl:declaration">
<xs:annotation>
<xs:documentation>
<p>Declaration of the <code>xsl:param</code> element, used both defining function
parameters, template parameters, parameters to <code>xsl:iterate</code>,
and global stylesheet parameters.</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="required" type="xsl:yes-or-no"/>
<xs:attribute name="tunnel" type="xsl:yes-or-no"/>
<xs:attribute name="static" type="xsl:yes-or-no"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_required" type="xs:string"/>
<xs:attribute name="_tunnel" type="xs:string"/>
<xs:attribute name="_static" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
<xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1'))
then empty((*,text()))
else true()">
<xs:annotation>
<xs:documentation>
<p>
When the attribute <code>static="yes"</code> is specified, the <code>xsl:param</code>
element must have empty content.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="perform-sort" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:sort" minOccurs="1" maxOccurs="unbounded"/>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:assert test="every $e in subsequence(xsl:sort, 2)
satisfies empty($e/(@stable | @_stable))">
<xs:annotation>
<xs:documentation>
<p>
It is a static error if an <code>xsl:sort</code> element other than the first
in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
attribute.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="preserve-space" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="elements" type="xsl:nametests"/>
<xs:attribute name="_elements" type="xs:string"/>
<xs:assert test="exists(@elements | @_elements)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="processing-instruction" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="name" type="xsl:avt"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="result-document" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="format" type="xsl:avt"/>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="href" type="xsl:avt"/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="method" type="xsl:avt"/>
<xs:attribute name="allow-duplicate-names" type="xsl:avt"/>
<xs:attribute name="build-tree" type="xsl:avt"/>
<xs:attribute name="byte-order-mark" type="xsl:avt"/>
<xs:attribute name="cdata-section-elements" type="xsl:avt"/>
<xs:attribute name="doctype-public" type="xsl:avt"/>
<xs:attribute name="doctype-system" type="xsl:avt"/>
<xs:attribute name="encoding" type="xsl:avt"/>
<xs:attribute name="escape-solidus" type="xsl:avt"/>
<xs:attribute name="escape-uri-attributes" type="xsl:avt"/>
<xs:attribute name="html-version" type="xsl:avt"/>
<xs:attribute name="include-content-type" type="xsl:avt"/>
<xs:attribute name="indent" type="xsl:avt"/>
<xs:attribute name="item-separator" type="xsl:avt"/>
<xs:attribute name="json-lines" type="xsl:avt"/>
<xs:attribute name="json-node-output-method" type="xsl:avt"/>
<xs:attribute name="media-type" type="xsl:avt"/>
<xs:attribute name="normalization-form" type="xsl:avt"/>
<xs:attribute name="omit-xml-declaration" type="xsl:avt"/>
<xs:attribute name="parameter-document" type="xsl:avt"/>
<xs:attribute name="standalone" type="xsl:avt"/>
<xs:attribute name="suppress-indentation" type="xsl:avt"/>
<xs:attribute name="undeclare-prefixes" type="xsl:avt"/>
<xs:attribute name="use-character-maps" type="xsl:EQNames"/>
<xs:attribute name="output-version" type="xsl:avt"/>
<xs:attribute name="_format" type="xs:string"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_href" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:attribute name="_method" type="xs:string"/>
<xs:attribute name="_byte-order-mark" type="xs:string"/>
<xs:attribute name="_cdata-section-elements" type="xs:string"/>
<xs:attribute name="_doctype-public" type="xs:string"/>
<xs:attribute name="_doctype-system" type="xs:string"/>
<xs:attribute name="_encoding" type="xs:string"/>
<xs:attribute name="_escape-solidus" type="xs:string"/>
<xs:attribute name="_escape-uri-attributes" type="xs:string"/>
<xs:attribute name="_html-version" type="xs:string"/>
<xs:attribute name="_include-content-type" type="xs:string"/>
<xs:attribute name="_indent" type="xs:string"/>
<xs:attribute name="_item-separator" type="xs:string"/>
<xs:attribute name="_media-type" type="xs:string"/>
<xs:attribute name="_normalization-form" type="xs:string"/>
<xs:attribute name="_omit-xml-declaration" type="xs:string"/>
<xs:attribute name="_parameter-document" type="xs:string"/>
<xs:attribute name="_standalone" type="xs:string"/>
<xs:attribute name="_suppress-indentation" type="xs:string"/>
<xs:attribute name="_undeclare-prefixes" type="xs:string"/>
<xs:attribute name="_use-character-maps" type="xs:string"/>
<xs:attribute name="_output-version" type="xs:string"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="sequence"
substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="_as" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="sort">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="lang" type="xsl:avt"/>
<xs:attribute name="data-type" type="xsl:avt"/>
<xs:attribute name="order" type="xsl:avt" default="ascending"/>
<xs:attribute name="case-order" type="xsl:avt"/>
<xs:attribute name="collation" type="xsl:avt"/>
<xs:attribute name="stable" type="xsl:avt"/>
<xs:attribute name="_lang" type="xs:string"/>
<xs:attribute name="_data-type" type="xs:string"/>
<xs:attribute name="_order" type="xs:string"/>
<xs:attribute name="_case-order" type="xs:string"/>
<xs:attribute name="_collation" type="xs:string"/>
<xs:attribute name="_stable" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="source-document" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="href" type="xsl:avt"/>
<xs:attribute name="streamable" type="xsl:yes-or-no" default="no"/>
<xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
<xs:attribute name="type" type="xsl:EQName"/>
<xs:attribute name="validation" type="xsl:validation-type"/>
<xs:attribute name="_href" type="xs:string"/>
<xs:attribute name="_streamable" type="xs:string"/>
<xs:attribute name="_use-accumulators" type="xs:string"/>
<xs:attribute name="_type" type="xs:string"/>
<xs:attribute name="_validation" type="xs:string"/>
<xs:assert test="exists(@href | @_href)"/>
<xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
<xs:annotation>
<xs:documentation>
<p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
(if one is present, the other must be absent).</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="strip-space" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:attribute name="elements" type="xsl:nametests"/>
<xs:attribute name="_elements" type="xs:string"/>
<xs:assert test="exists(@elements | @_elements)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="stylesheet" substitutionGroup="xsl:transform"/>
<xs:element name="switch" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:when" maxOccurs="unbounded"/>
<xs:element ref="xsl:otherwise" minOccurs="0"/>
<xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="_select" type="xsl:avt"/>
<xs:assert test="exists(@select | @_select)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="template" substitutionGroup="xsl:declaration">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:element ref="xsl:context-item" minOccurs="0" maxOccurs="1"/>
<xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="match" type="xsl:pattern"/>
<xs:attribute name="priority" type="xs:decimal"/>
<xs:attribute name="mode" type="xsl:modes"/>
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="as" type="xsl:sequence-type" default="item()*"/>
<xs:attribute name="visibility" type="xsl:visibility-type"/>
<xs:attribute name="_match" type="xs:string"/>
<xs:attribute name="_priority" type="xs:string"/>
<xs:attribute name="_mode" type="xs:string"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
<xs:assert test="exists(@match | @_match) or exists(@name | @_name)">
<xs:annotation>
<xs:documentation>
<p>
An <code>xsl:template</code> element must have either a <code>match</code> attribute or a
<code>name</code> attribute, or both.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (empty(@match | @_match))
then (empty(@mode | @_mode) and empty(@priority | @_priority))
else true()">
<xs:annotation>
<xs:documentation>
<p>
An <code>xsl:template</code> element that has no <code>match</code> attribute must have no
<code>mode</code> attribute and no <code>priority</code> attribute.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="not(exists(@visibility | @_visibility) and empty(@name | @_name))">
<xs:annotation>
<xs:documentation>
<p>
An <code>xsl:template</code> element that has no <code>name</code> attribute must have no
<code>visibility</code> attribute
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (normalize-space(@visibility) = 'abstract')
then empty(* except (xsl:context-item, xsl:param))
else true()">
<xs:annotation>
<xs:documentation>
<p>
If the <code>visibility</code> attribute is present with the value <code>abstract</code>
then (a) the sequence constructor defining the template body
must be empty: that is, the only permitted children are
<code>xsl:context-item</code> and <code>xsl:param</code>
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="not(normalize-space(@visibility) = 'abstract' and exists(@match))">
<xs:annotation>
<xs:documentation>
<p>
If the <code>visibility</code> attribute is present with the value <code>abstract</code>
then there must be no <code>match</code> attribute.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $e in xsl:param satisfies empty($e/(@visibility | @_visibility))">
<xs:annotation>
<xs:documentation>
<p>A parameter for a template must have no <code>visibility</code> attribute.</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="text-element-base-type">
<xs:simpleContent>
<xs:restriction base="xsl:versioned-element-type">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="text-element-type">
<xs:simpleContent>
<xs:extension base="xsl:text-element-base-type">
<xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/>
<xs:attribute name="_disable-output-escaping" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:element name="text"
substitutionGroup="xsl:instruction"
type="xsl:text-element-type"/>
<xs:complexType name="transform-element-base-type">
<xs:complexContent>
<xs:restriction base="xsl:element-only-versioned-element-type">
<xs:attribute name="version" type="xs:decimal" use="optional"/>
<xs:attribute name="_version" type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
The version attribute indicates the version of XSLT that the
stylesheet module requires. The attribute is required, unless the
<code>xsl:stylesheet</code> element is a child of an <code>xsl:package</code> element, in
which case it is optional: the default is then taken from the
parent <code>xsl:package</code> element.
</p>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="transform">
<xs:complexType>
<xs:complexContent>
<xs:extension base="xsl:transform-element-base-type">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:declaration"/>
<xs:any namespace="##other" processContents="lax"/>
<!-- weaker than XSLT 1.0 -->
</xs:choice>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="input-type-annotations"
type="xsl:input-type-annotations-type"
default="unspecified"/>
<xs:attribute name="fixed-namespaces"
type="xsl:fixed-namespaces-type"/>
<xs:attribute name="_id" type="xs:string"/>
<xs:attribute name="_input-type-annotations" type="xs:string"/>
<xs:attribute name="_fixed-namespaces" type="xs:string"/>
<!--* The 'static' attribute may be used on 'param' and 'variable'
* only when they are top-level elements. *-->
<xs:assert test="every $v in (.//xsl:param, .//xsl:variable)[exists(@static | @_static)]
satisfies $v[parent::xsl:stylesheet or parent::xsl:transform or parent::xsl:override]">
<xs:annotation>
<xs:documentation>
<p>
The static attribute must not be present on an <code>xsl:variable</code> or
<code>xsl:param</code> element unless it is a top-level element.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $prefix in (@exclude-result-prefixes[not(. = '#all')],
@extension-element-prefixes)
satisfies ((if ($prefix = '#default') then '' else $prefix) = in-scope-prefixes(.))">
<xs:annotation>
<xs:documentation>
<p>
XTSE0808: It is a static error if a namespace prefix is used
within the <code>[xsl:]exclude-result-prefixes</code> attribute and there is
no namespace binding in scope for that prefix.
</p>
<p>
XTSE0809: It is a static error if the value #default is used
within the <code>[xsl:]exclude-result-prefixes</code> attribute and the
parent element of the <code>[xsl:]exclude-result-prefixes</code> attribute
has no default namespace.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="try" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:versioned-element-type">
<xs:sequence>
<xs:group ref="xsl:sequence-constructor-group"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element ref="xsl:catch" minOccurs="1" maxOccurs="1"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:catch"/>
<xs:element ref="xsl:fallback"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="rollback-output" type="xsl:yes-or-no" default="yes"/>
<xs:attribute name="select" type="xsl:expression" use="optional"/>
<xs:attribute name="_rollback-output" type="xs:string"/>
<xs:attribute name="_select" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="use-package" substitutionGroup="xsl:declaration">
<xs:annotation>
<xs:documentation>
<p>This element appears as a child of <code>xsl:package</code> and defines a dependency
of the containing package on another package, identified by URI in the <code>name</code>
attribute. The <code>package-version</code> attribute indicates which version of the
library package is required, or may indicate a range of versions.</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent mixed="false">
<xs:extension base="xsl:element-only-versioned-element-type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xsl:accept"/>
<xs:element ref="xsl:override"/>
</xs:choice>
<xs:attribute name="name" type="xs:anyURI"/>
<xs:attribute name="package-version" type="xs:string"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_package-version" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="value-of" substitutionGroup="xsl:instruction">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="separator" type="xsl:avt"/>
<xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/>
<xs:attribute name="_separator" type="xs:string"/>
<xs:attribute name="_disable-output-escaping" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="variable" substitutionGroup="xsl:declaration xsl:instruction">
<xs:annotation>
<xs:documentation>
<p>Declaration of the <code>xsl:variable</code> element, used both for local
and global variable bindings.</p>
<p>
This definition takes advantage of the ability in XSD 1.1 for an element
to belong to more than one substitution group. A global variable is a
declaration, while a local variable can appear as an instruction in a
sequence constructor.
</p>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="visibility" type="xsl:visibility-type"/>
<xs:attribute name="static" type="xsl:yes-or-no"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_visibility" type="xs:string"/>
<xs:attribute name="_static" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
<xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1'))
then (exists(@_visibility) or normalize-space(@visibility)
= ('', 'private', 'final'))
else true()">
<xs:annotation>
<xs:documentation>
<p>
When the static attribute is present with the value yes, the
visibility attribute must not have a value other than private or
final.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1'))
then (empty((*, text())) and exists(@select | @_select))
else true()">
<xs:annotation>
<xs:documentation>
<p>
When the attribute <code>static="yes"</code> is specified, the <code>xsl:variable</code>
element must have empty content, and the <code>select</code> attribute must
be present to define the value of the variable.
</p>
</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="when">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor">
<xs:attribute name="select" type="xsl:expression"/>
<xs:attribute name="test" type="xsl:expression"/>
<xs:attribute name="_select" type="xs:string"/>
<xs:attribute name="_test" type="xs:string"/>
<xs:assert test="exists(@test | @_test)"/>
<xs:assert test="not(exists(@select | @_select) and
(exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="where-populated"
substitutionGroup="xsl:instruction"
type="xsl:sequence-constructor"/>
<xs:element name="with-param">
<xs:complexType>
<xs:complexContent mixed="true">
<xs:extension base="xsl:sequence-constructor-or-select">
<xs:attribute name="name" type="xsl:EQName"/>
<xs:attribute name="as" type="xsl:sequence-type"/>
<xs:attribute name="tunnel" type="xsl:yes-or-no"/>
<xs:attribute name="_name" type="xs:string"/>
<xs:attribute name="_as" type="xs:string"/>
<xs:attribute name="_tunnel" type="xs:string"/>
<xs:assert test="exists(@name | @_name)"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation> PART C: definition of literal result elements There are three ways to define
the literal result elements permissible in a stylesheet. (a) do nothing. This allows any
element to be used as a literal result element, provided it is not in the XSLT namespace (b)
declare all permitted literal result elements as members of the <code>xsl:literal-result-element</code>
substitution group (c) redefine the model group xsl:result-elements to accommodate all
permitted literal result elements. Literal result elements are allowed to take certain
attributes in the XSLT namespace. These are defined in the attribute group
<code>literal-result-element-attributes</code>, which can be included in the definition of any literal
result element. </xs:documentation>
</xs:annotation>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="literal-result-element" abstract="true" type="xs:anyType"/>
<xs:attributeGroup name="literal-result-element-attributes">
<xs:attribute name="default-collation" form="qualified" type="xsl:uri-list"/>
<xs:attribute name="default-mode" type="xsl:default-mode-type"/>
<xs:attribute name="default-validation"
type="xsl:validation-strip-or-preserve"
default="strip"/>
<xs:attribute name="expand-text" type="xsl:yes-or-no"/>
<xs:attribute name="extension-element-prefixes" form="qualified" type="xsl:prefixes"/>
<xs:attribute name="exclude-result-prefixes" form="qualified" type="xsl:prefixes"/>
<xs:attribute name="xpath-default-namespace" form="qualified" type="xs:anyURI"/>
<xs:attribute name="inherit-namespaces"
form="qualified"
type="xsl:yes-or-no"
default="yes"/>
<xs:attribute name="use-attribute-sets"
form="qualified"
type="xsl:EQNames"
default=""/>
<xs:attribute name="use-when" form="qualified" type="xsl:expression"/>
<xs:attribute name="version" form="qualified" type="xs:decimal"/>
<xs:attribute name="type" form="qualified" type="xsl:EQName"/>
<xs:attribute name="validation" form="qualified" type="xsl:validation-type"/>
</xs:attributeGroup>
<xs:group name="result-elements">
<xs:choice>
<xs:element ref="xsl:literal-result-element"/>
<xs:any namespace="##other" processContents="lax"/>
<xs:any namespace="##local" processContents="lax"/>
</xs:choice>
</xs:group>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:annotation>
<xs:documentation>
<p>
PART D: definitions of simple types used in stylesheet attributes
</p>
</xs:documentation>
</xs:annotation>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:simpleType name="accumulator-names">
<xs:annotation>
<xs:documentation>
<p>
The <code>use-accumulators</code> attribute of <code>xsl:source-document</code>,
<code>xsl:merge-source</code>, or <code>xsl:global-context-item</code>:
either a list, each member being a QName; or the value <code>#all</code>
</p>
</xs:documentation>
</xs:annotation>
<xs:union>
<xs:simpleType>
<xs:list itemType="xsl:EQName"/>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#all"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="avt">
<xs:annotation>
<xs:documentation>
<p>
This type is used for all attributes that allow an attribute value
template. The general rules for the syntax of attribute value templates,
and the specific rules for each such attribute, are described in the
XSLT 4.0 Recommendation.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="char">
<xs:annotation>
<xs:documentation>
<p>
A string containing exactly one character.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:length value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="char-optionally-expanded">
<xs:annotation>
<xs:documentation>
<p>
A string containing either a single character, or a single character
followed by a colon followed by an arbitrary string
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value=".(:.*)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="component-kind-type">
<xs:annotation>
<xs:documentation>
<p>
Describes a kind of component within a package.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="template"/>
<xs:enumeration value="function"/>
<xs:enumeration value="variable"/>
<xs:enumeration value="attribute-set"/>
<xs:enumeration value="mode"/>
<xs:enumeration value="*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="default-mode-type">
<xs:annotation>
<xs:documentation>
<p>
The <code>default-mode</code> attribute of <code>xsl:stylesheet</code>,
<code>xsl:transform</code>, <code>xsl:package</code>
(or any other xsl:* element): either a QName or #unnamed.
</p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xsl:EQName">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#unnamed"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="component-test">
<xs:annotation>
<xs:documentation>
<p> A NameTest or a named function reference. </p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xsl:nametest xsl:named-function-reference"/>
</xs:simpleType>
<xs:simpleType name="component-tests">
<xs:annotation>
<xs:documentation>
<p> A list of NameTests or named function references</p>
</xs:documentation>
</xs:annotation>
<xs:list itemType="xsl:component-test"/>
</xs:simpleType>
<xs:simpleType name="expression">
<xs:annotation>
<xs:documentation>
<p>
An XPath 4.0 expression.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value=".+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="fixed-namespaces-type">
<xs:annotation>
<xs:documentation>
<p>
A sequence of tokens, each of which may be one of #default, an NCName, a prefix=namespace binding, or a URI
</p>
</xs:documentation>
</xs:annotation>
<xs:list>
<xs:simpleType>
<xs:union memberTypes="xsl:fixed-namespaces-type-default xs:NCName xsl:fixed-namespaces-type-prefix-binding xs:anyURI"/>
</xs:simpleType>
</xs:list>
</xs:simpleType>
<xs:simpleType name="fixed-namespaces-type-default">
<xs:restriction base="xs:string">
<xs:enumeration value="#default"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="fixed-namespaces-type-prefix-binding">
<xs:restriction base="xs:string">
<xs:pattern value="([\i-[:]][\c-[:]]*:)=.+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="item-type">
<xs:annotation>
<xs:documentation>
<p>
An XPath 4.0 ItemType
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value=".+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="input-type-annotations-type">
<xs:annotation>
<xs:documentation>
<p>
Describes how type annotations in source documents are handled.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="preserve"/>
<xs:enumeration value="strip"/>
<xs:enumeration value="unspecified"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="level">
<xs:annotation>
<xs:documentation>
<p>
The <code>level</code> attribute of <code>xsl:number</code>:
one of <code>single</code>, <code>multiple</code>, or <code>any</code>.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="single"/>
<xs:enumeration value="multiple"/>
<xs:enumeration value="any"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="mode">
<xs:annotation>
<xs:documentation>
<p>
The <code>mode</code> attribute of <code>xsl:apply-templates</code>:
either a QName, or <code>#current</code>,
or <code>#unnamed</code>, or <code>#default</code>.
</p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xsl:EQName">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#default"/>
<xs:enumeration value="#unnamed"/>
<xs:enumeration value="#current"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="modes">
<xs:annotation>
<xs:documentation>
<p>
The <code>mode</code> attribute of <code>xsl:template</code>: either a list, each member being
either a QName or <code>#default</code> or <code>#unnamed</code>; or the value <code>#all</code>
</p>
</xs:documentation>
</xs:annotation>
<xs:union>
<xs:simpleType>
<xs:restriction>
<xs:simpleType>
<xs:list>
<xs:simpleType>
<xs:union memberTypes="xsl:EQName">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#default"/>
<xs:enumeration value="#unnamed"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:list>
</xs:simpleType>
<xs:assertion test="count($value) = count(distinct-values($value))">
<xs:annotation>
<xs:documentation>
<p>
XTSE0550: It is a static error if the same token is included
more than once in the list.
</p>
</xs:documentation>
</xs:annotation>
</xs:assertion>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#all"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="named-function-reference">
<xs:annotation>
<xs:documentation>
<p> In simple terms, this is an EQName followed by "#arity" where "arity" is a non-negative integer. However,
XSD doesn't allow us to reuse the definition of EQName in this way, so it has to be defined from scratch. The simplest
way to do this is with an assertion. However, the assertion cannot exploit types such as <code>xsl:EQName</code> defined in this
schema</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="((Q\{.*\})|([\i-[:]][\c-[:]]*:))?[\i-[:]][\c-[:]]*#[0-9]+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="nametest">
<xs:annotation>
<xs:documentation>
<p> A list of NameTests, as defined in the XPath 31 Recommendation. Each NameTest is either
an EQName, or "*", or "prefix:*", or "*:localname", or the wildcard Q{uri}*. </p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xsl:EQName">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[\i-[:]][\c-[:]]*:\*"/>
<xs:pattern value="\*:[\i-[:]][\c-[:]]*"/>
<xs:pattern value="Q\{[^}]*\}\*"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="nametests">
<xs:annotation>
<xs:documentation>
<p> A list of NameTests, as defined in the XPath 4.0 Recommendation. Each NameTest is either
a QName, or "*", or "prefix:*", or "*:localname" </p>
</xs:documentation>
</xs:annotation>
<xs:list itemType="xsl:nametest"/>
</xs:simpleType>
<xs:simpleType name="on-multiple-match-type">
<xs:annotation>
<xs:documentation>
<p>
Describes the action to be taken when there are several template rules
to match an item in a given mode.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="use-last"/>
<xs:enumeration value="fail"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="on-no-match-type">
<xs:annotation>
<xs:documentation>
<p>
Describes the action to be taken when there is no template rule to match
an item in a given mode.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="deep-copy"/>
<xs:enumeration value="shallow-copy"/>
<xs:enumeration value="shallow-copy-all"/>
<xs:enumeration value="deep-skip"/>
<xs:enumeration value="shallow-skip"/>
<xs:enumeration value="text-only-copy"/>
<xs:enumeration value="fail"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="prefixes">
<xs:list itemType="xs:NCName"/>
</xs:simpleType>
<xs:simpleType name="prefix-list-or-all">
<xs:union memberTypes="xsl:prefix-list">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#all"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="prefix-list">
<xs:list itemType="xsl:prefix-or-default"/>
</xs:simpleType>
<xs:simpleType name="method">
<xs:annotation>
<xs:documentation>
<p>
The <code>method</code> attribute of <code>xsl:output</code>: Either one of the recognized names
"xml", "xhtml", "html", "text", "json", or "adaptive",
or a QName that must include a prefix.
</p>
</xs:documentation>
</xs:annotation>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xml"/>
<xs:enumeration value="xhtml"/>
<xs:enumeration value="html"/>
<xs:enumeration value="text"/>
<xs:enumeration value="json"/>
<xs:enumeration value="adaptive"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xsl:EQName">
<xs:pattern value="\c*:\c*"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="pattern">
<xs:annotation>
<xs:documentation>
<p>
A match pattern as defined in the XSLT 4.0 Recommendation. The syntax
for patterns is a restricted form of the syntax for XPath 4.0
expressions.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xsl:expression"/>
</xs:simpleType>
<xs:simpleType name="prefix-or-default">
<xs:annotation>
<xs:documentation>
<p>
Either a namespace prefix, or <code>#default</code>. Used in the <code>xsl:namespace-alias</code>
element.
</p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xs:NCName">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="#default"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="EQNames">
<xs:annotation>
<xs:documentation>
<p>
A list of QNames. Used in the <code>[xsl:]use-attribute-sets</code> attribute of
various elements, and in the <code>cdata-section-elements</code> attribute of
<code>xsl:output</code>.
</p>
</xs:documentation>
</xs:annotation>
<xs:list itemType="xsl:EQName"/>
</xs:simpleType>
<xs:simpleType name="EQName">
<xs:annotation>
<xs:documentation>
<p>
An extended QName. This schema does not use the built-in type <code>xs:QName</code>,
but rather defines its own QName type. This may be either a local name,
or a prefixed QName, or a name written using the extended QName notation
<code>Q{uri}local</code>
</p>
<p>In XSLT 4.0, where a QName is used in the <code>name</code> attribute
of (say) <code>xsl:template</code> or <code>xsl:call-template</code>, the prefix
does not have to be bound in an XML namespace declaration; rather it can be bound
in a <code>fixed-namespaces</code> attribute on the <code>xsl:stylesheet</code>
element. Therefore, the built-in <code>xs:QName</code> type cannot be used.
This schema does not attempt to verify that namespace prefixes have been
properly declared.</p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xs:NCName">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[\i-[:]][\c-[:]]*:[\i-[:]][\c-[:]]*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="Q\{[^{}]*\}[\i-[:]][\c-[:]]*"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="EQName-in-namespace">
<xs:annotation>
<xs:documentation>
<p>
A subtype of EQNames that excludes no-namespace names
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xsl:EQName">
<xs:pattern value="Q\{.+\}.+|\i\c*:.+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="sequence-type">
<xs:annotation>
<xs:documentation>
<p>
The description of a datatype, conforming to the SequenceType production
defined in the XPath 4.0 Recommendation
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value=".+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="streamability-type">
<xs:annotation>
<xs:documentation>
<p>
Describes the category to which a function belongs, with regards to its
streaming behavior.
</p>
</xs:documentation>
</xs:annotation>
<xs:union memberTypes="xsl:EQName-in-namespace">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="unclassified"/>
<xs:enumeration value="absorbing"/>
<xs:enumeration value="inspection"/>
<xs:enumeration value="filter"/>
<xs:enumeration value="shallow-descent"/>
<xs:enumeration value="deep-descent"/>
<xs:enumeration value="ascent"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="typed-type">
<xs:annotation>
<xs:documentation>
<p>
Describes whether a mode is designed to match typed or untyped nodes.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
<xs:enumeration value="1"/>
<xs:enumeration value="0"/>
<xs:enumeration value="strict"/>
<xs:enumeration value="lax"/>
<xs:enumeration value="unspecified"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="uri-list">
<xs:list itemType="xs:anyURI"/>
</xs:simpleType>
<xs:simpleType name="validation-strip-or-preserve">
<xs:annotation>
<xs:documentation>
<p>
Describes different ways of type-annotating an element or attribute.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xsl:validation-type">
<xs:enumeration value="preserve"/>
<xs:enumeration value="strip"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="validation-type">
<xs:annotation>
<xs:documentation>
<p>
Describes different ways of type-annotating an element or attribute.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="strict"/>
<xs:enumeration value="lax"/>
<xs:enumeration value="preserve"/>
<xs:enumeration value="strip"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="visibility-type">
<xs:annotation>
<xs:documentation>
<p>
Describes the visibility of a component within a package.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="public"/>
<xs:enumeration value="private"/>
<xs:enumeration value="final"/>
<xs:enumeration value="abstract"/>
<xs:enumeration value="hidden"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="visibility-not-hidden-type">
<xs:annotation>
<xs:documentation>
<p>
Describes the visibility of a component within a package.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xsl:visibility-type">
<xs:enumeration value="public"/>
<xs:enumeration value="private"/>
<xs:enumeration value="final"/>
<xs:enumeration value="abstract"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="yes-or-no">
<xs:annotation>
<xs:documentation>
<p>
One of the values "yes" or "no": the values "true" or "false", or "1" or
"0" are accepted as synonyms.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
<xs:enumeration value="1"/>
<xs:enumeration value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="yes-or-no-or-maybe">
<xs:annotation>
<xs:documentation>
<p>
One of the values "yes" or "no" or "omit". The values "true" or "false",
or "1" or "0" are accepted as synonyms of "yes" and "no" respectively.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
<xs:enumeration value="1"/>
<xs:enumeration value="0"/>
<xs:enumeration value="maybe"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="yes-or-no-or-omit">
<xs:annotation>
<xs:documentation>
<p>
One of the values "yes" or "no" or "omit". The values "true" or "false",
or "1" or "0" are accepted as synonyms of "yes" and "no" respectively.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
<xs:enumeration value="1"/>
<xs:enumeration value="0"/>
<xs:enumeration value="omit"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="zero-digit">
<xs:annotation>
<xs:documentation>
<p>
A digit that has the numerical value zero.
</p>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xsl:char">
<xs:pattern value="\p{Nd}"/>
<xs:assertion test="matches(string-join(codepoints-to-string(
for $i in 0 to 9 return string-to-codepoints($value) + $i), ''), '\p{Nd}{10}')"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
The following Relax-NG schema may be used to validate XSLT 4.0 stylesheet modules. Similar caveats apply as for the XSD 1.1 version.
A copy of this schema is available at schema-for-xslt30.rnc
TODO: Needs updating for 4.0.
# XSLT 4.0 Relax NG Schema
#
# Copyright (c) 2010-2016, Mohamed ZERGAOUI (Innovimax)
# Portions © 2024, XQuery and XSLT Extensions Community Group
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer. Redistributions in binary
# form must reproduce the above copyright notice, this list of conditions and
# the following disclaimer in the documentation and/or other materials provided
# with the distribution. Neither the name of the Mohamed ZERGAOUI or Innovimax
# nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
namespace local = ""
default namespace xsl = "http://www.w3.org/1999/XSL/Transform"
namespace xs = "http://www.w3.org/2001/XMLSchema"
start =
stylesheet.element
| transform.element
| package.element
| literal-result-element-as-stylesheet
sequence-constructor.model = (instruction.category | literal-result-element | text)*
literal-result-element-as-stylesheet =
element * - xsl:* {
attribute xsl:version { decimal.datatype },
literal-result-element-no-version.atts,
sequence-constructor.model
}
literal-result-element =
element * - xsl:* {
literal-result-element.atts,
sequence-constructor.model
}
literal-result-element.atts =
literal-result-element-no-version.atts,
attribute xsl:version { text }?
# These attributes may also appear on a literal result element, but in this case, to distinguish them from user-defined attributes,
# the names of the attributes are in the XSLT namespace. They are thus typically written as
# xsl:default-collation,
# xsl:default-mode,
# xsl:default-validation,
# xsl:exclude-result-prefixes,
# xsl:expand-text,
# xsl:extension-element-prefixes,
# xsl:use-when,
# xsl:version,
# or xsl:xpath-default-namespace.
literal-result-element-no-version.atts =
attribute * - xsl:* { avt.datatype }*
& attribute xsl:default-collation { uris.datatype }?
& attribute xsl:default-mode { eqname.datatype | '#unnamed' }?
& attribute xsl:default-validation { "preserve" | "strip" }?
& attribute xsl:exclude-result-prefixes { exclude.prefixes.datatype }? # or prefixes.datatype ?
& attribute xsl:expand-text { boolean.datatype }?
& attribute xsl:extension-element-prefixes { extension.prefixes.datatype }? # or prefixes.datatype ?
& attribute xsl:inherit-namespaces { boolean.datatype }?
& attribute xsl:on-empty { expression.datatype }?
& attribute xsl:use-attribute-sets { eqnames.datatype }?
& attribute xsl:use-when { expression.datatype }?
& attribute xsl:xpath-default-namespace { xsd:anyURI }?
& (attribute xsl:type { eqname.datatype }
| attribute xsl:validation { "strict" | "lax" | "preserve" | "strip" })?
top-level-extension =
element * - (xsl:* | local:*) {
anyElement
}
anyElement =
grammar {
start = any
any =
(attribute * { text }
| text
| element * { any })*
}
extension.atts = attribute * - (xsl:* | local:*) { text }*
declarations.model = (declaration.category | top-level-extension)*
# [Definition: There are a number of standard attributes that may appear on any XSLT element: specifically
# default-collation,
# default-mode,
# default-validation,
# exclude-result-prefixes,
# expand-text,
# extension-element-prefixes,
# use-when,
# version,
# and xpath-default-namespace.]
global.atts =
attribute default-collation { uris.datatype }?,
attribute _default-collation { avt.datatype }?,
attribute default-mode { eqname.datatype | '#unnamed' }?,
attribute _default-mode { avt.datatype }?,
attribute default-validation { "preserve" | "strip" }?,
attribute _default-validation { avt.datatype }?,
attribute exclude-result-prefixes { exclude.prefixes.datatype }?,
attribute _exclude-result-prefixes { avt.datatype }?, # or prefixes.datatype ?
attribute expand-text { boolean.datatype }?,
attribute _expand-text { avt.datatype }?,
attribute extension-element-prefixes { extension.prefixes.datatype }?,
attribute _extension-element-prefixes { avt.datatype }?, # or prefixes.datatype ?
attribute use-when { expression.datatype }?,
attribute _use-when { avt.datatype }?,
attribute version { decimal.datatype }?,
attribute _version { avt.datatype }?,
attribute xpath-default-namespace { uri.datatype }?,
attribute _xpath-default-namespace { avt.datatype }?
global.atts.except.version =
attribute default-collation { uris.datatype }?,
attribute _default-collation { avt.datatype }?,
attribute exclude-result-prefixes { exclude.prefixes.datatype }?,
attribute _exclude-result-prefixes { avt.datatype }?, # or prefixes.datatype ?
attribute expand-text { boolean.datatype }?,
attribute _expand-text { avt.datatype }?,
attribute extension-element-prefixes { extension.prefixes.datatype }?,
attribute _extension-element-prefixes { avt.datatype }?, # or prefixes.datatype ?
attribute use-when { expression.datatype }?,
attribute _use-when { avt.datatype }?,
attribute xpath-default-namespace { uri.datatype }?,
attribute _xpath-default-namespace { avt.datatype }?
# In XSLT 4.0, prefixes can be defined with the fixed-namespaces attribute
# on the xsl:stylesheet, so we can't rely on XML declarations for QNames.
qname.strict = xsd:token { pattern = "[\i-[:]][\c-[:]]*:[\i-[:]][\c-[:]]*" }
qname.datatype = xsd:NCName | qname.strict
# Extract from XPath 3.0
#[94] EQName ::= QName | URIQualifiedName
#[104] QName ::= [http://www.w3.org/TR/REC-xml-names/#NT-QName]Names
#[105] NCName ::= [http://www.w3.org/TR/REC-xml-names/#NT-NCName]Names
#[99] URIQualifiedName ::= BracedURILiteral NCName
#[100] BracedURILiteral ::= "Q" "{" [^{}]* "}"
uri.qualified.name = xsd:token { pattern = "Q\{[^\{\}]*\}[\i-[:]][\c-[:]]*" }
eqname.datatype = qname.datatype | uri.qualified.name
qnames.datatype = list { qname.datatype* }
eqnames.datatype = list { eqname.datatype* }
ncname.datatype = xsd:NCName
prefix.datatype = xsd:NCName
boolean.datatype = "yes" | "no" | "true" | "false" | "0" | "1"
expression.datatype = text
char.datatype = xsd:string { length = "1" }
string.datatype = text
id.datatype = xsd:NCName
tokens.datatype = list { token* }
prefixes.datatype = list { token* }
extension.prefixes.datatype = list { xsd:NCName* }
exclude.prefixes.datatype = list { "#all" | (xsd:NCName | "#default")* }
token.datatype = token
language.datatype = xsd:language
nmtoken.datatype = xsd:NMTOKEN
decimal.datatype = xsd:decimal
integer.datatype = xsd:integer
uri.datatype = xsd:anyURI
uris.datatype = list { xsd:anyURI* }
pattern.datatype = text
qname-but-not-ncname.datatype = xsd:QName { pattern = ".*:.*" }
xs_schema.element = element xs:schema { anyElement* }
item-type.datatype = text
sequence-type.datatype = text
# #standard or NCName or prefix=URI or URI
fixed-namespaces.datatype = xsd:string
select-or-sequence-constructor.model =
((attribute select { expression.datatype }
| attribute _select { avt.datatype })+
| sequence-constructor.model)
declaration.category =
use-package.element
| include.element
| import.element
| import-schema.element
| strip-space.element
| preserve-space.element
| decimal-format.element
| template.element
| mode.element
| global-context-item.element
| variable.element
| param.element
| attribute-set.element
| function.element
| namespace-alias.element
| accumulator.element
| key.element
| output.element
| character-map.element
instruction.category =
apply-templates.element
| apply-imports.element
| next-match.element
| for-each.element
| iterate.element
| next-iteration.element
| break.element
| if.element
| choose.element
| switch.element
| try.element
| variable.element
| call-template.element
| evaluate.element
| element.element
| attribute.element
| text.element
| value-of.element
| document.element
| processing-instruction.element
| namespace.element
| comment.element
| copy.element
| copy-of.element
| sequence.element
| where-populated.element
| on-empty.element
| on-non-empty.element
| number.element
| perform-sort.element
| for-each-group.element
| merge.element
| fork.element
| analyze-string.element
| source-document.element
| map.element
| map-entry.element
| array.element
| array-member.element
| message.element
| assert.element
| fallback.element
| result-document.element
package.element =
element package {
extension.atts,
attribute id { id.datatype }?,
attribute _id { avt.datatype }?,
attribute name { uri.datatype }?,
attribute _name { avt.datatype }?,
attribute package-version { string.datatype }?,
attribute _package-version { avt.datatype }?,
attribute version { decimal.datatype }?,
attribute _version { avt.datatype }?,
attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
attribute _input-type-annotations { avt.datatype }?,
attribute declared-modes { boolean.datatype }?,
attribute _declared-modes { avt.datatype }?,
attribute default-mode { eqname.datatype | "#unnamed" }?,
attribute _default-mode { avt.datatype }?,
attribute default-validation { "preserve" | "strip" }?,
attribute _default-validation { avt.datatype }?,
attribute default-collation { uris.datatype }?,
attribute _default-collation { avt.datatype }?,
attribute extension-element-prefixes { prefixes.datatype }?,
attribute _extension-element-prefixes { avt.datatype }?,
attribute exclude-result-prefixes { prefixes.datatype }?,
attribute _exclude-result-prefixes { avt.datatype }?,
attribute expand-text { boolean.datatype }?,
attribute _expand-text { avt.datatype }?,
attribute use-when { expression.datatype }?,
attribute _use-when { avt.datatype }?,
attribute xpath-default-namespace { uri.datatype }?,
attribute _xpath-default-namespace { avt.datatype }?,
attribute fixed-namespaces { fixed-namespaces.datatype }?,
attribute _fixed-namespaces { fixed-namespaces.datatype }?,
((expose.element | declarations.model)*)
}
use-package.element =
element use-package {
extension.atts,
global.atts,
attribute name { uri.datatype }?,
attribute _name { avt.datatype }?,
attribute package-version { string.datatype }?,
attribute _package-version { avt.datatype }?,
(accept.element | override.element)*
}
expose.element =
element expose {
extension.atts,
global.atts,
attribute component { "template" | "function" | "attribute-set" | "variable" | "mode" | "*" }?,
attribute _component { avt.datatype }?,
attribute names { tokens.datatype }?,
attribute _names { avt.datatype }?,
attribute visibility { "public" | "private" | "final" | "abstract" }?,
attribute _visibility { avt.datatype }?,
empty
}
accept.element =
element accept {
extension.atts,
global.atts,
(attribute component { "template" | "function" | "attribute-set" | "variable" | "mode" | "*" } |
attribute _component { avt.datatype })+,
(attribute names { tokens.datatype } |
attribute _names { avt.datatype })+,
(attribute visibility { "public" | "private" | "final" | "abstract" | "hidden" } |
attribute _visibility { avt.datatype })+,
empty
}
override.element =
element override {
extension.atts,
global.atts,
(template.element | function.element | variable.element | param.element | attribute-set.element)*
}
stylesheet.element =
element stylesheet {
extension.atts,
attribute id { id.datatype }?,
attribute _id { avt.datatype }?,
attribute version { decimal.datatype }?,
attribute _version { avt.datatype }?,
attribute default-mode { eqname.datatype | "#unnamed" }?,
attribute _default-mode { avt.datatype }?,
attribute default-validation { "preserve" | "strip" }?,
attribute _default-validation { avt.datatype }?,
attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
attribute _input-type-annotations { avt.datatype }?,
attribute default-collation { uris.datatype }?,
attribute _default-collation { avt.datatype }?,
attribute extension-element-prefixes { prefixes.datatype }?,
attribute _extension-element-prefixes { avt.datatype }?,
attribute exclude-result-prefixes { prefixes.datatype }?,
attribute _exclude-result-prefixes { avt.datatype }?,
attribute expand-text { boolean.datatype }?,
attribute _expand-text { avt.datatype }?,
attribute use-when { expression.datatype }?,
attribute _use-when { avt.datatype }?,
attribute xpath-default-namespace { uri.datatype }?,
attribute _xpath-default-namespace { avt.datatype }?,
attribute fixed-namespaces { fixed-namespaces.datatype }?,
attribute _fixed-namespaces { fixed-namespaces.datatype }?,
(declarations.model)
}
transform.element =
element transform {
extension.atts,
attribute id { id.datatype }?,
attribute _id { avt.datatype }?,
attribute version { decimal.datatype }?,
attribute _version { avt.datatype }?,
attribute default-mode { eqname.datatype | "#unnamed" }?,
attribute _default-mode { avt.datatype }?,
attribute default-validation { "preserve" | "strip" }?,
attribute _default-validation { avt.datatype }?,
attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
attribute _input-type-annotations { avt.datatype }?,
attribute default-collation { uris.datatype }?,
attribute _default-collation { avt.datatype }?,
attribute extension-element-prefixes { prefixes.datatype }?,
attribute _extension-element-prefixes { avt.datatype }?,
attribute exclude-result-prefixes { prefixes.datatype }?,
attribute _exclude-result-prefixes { avt.datatype }?,
attribute expand-text { boolean.datatype }?,
attribute _expand-text { avt.datatype }?,
attribute use-when { expression.datatype }?,
attribute _use-when { avt.datatype }?,
attribute xpath-default-namespace { uri.datatype }?,
attribute _xpath-default-namespace { avt.datatype }?,
attribute fixed-namespaces { fixed-namespaces.datatype }?,
attribute _fixed-namespaces { fixed-namespaces.datatype }?,
(declarations.model)
}
include.element =
element include {
extension.atts,
global.atts,
attribute href { uri.datatype }?,
attribute _href { avt.datatype }?,
empty
}
import.element =
element import {
extension.atts,
global.atts,
(attribute href { uri.datatype }
| attribute _href { avt.datatype })+,
empty
}
import-schema.element =
element import-schema {
extension.atts,
global.atts,
attribute namespace { uri.datatype }?,
attribute _namespace { avt.datatype }?,
attribute schema-location { uri.datatype }?,
attribute _schema-location { avt.datatype }?,
xs_schema.element?
}
strip-space.element =
element strip-space {
extension.atts,
global.atts,
(attribute elements { tokens.datatype }
| attribute _elements { avt.datatype })+,
empty
}
preserve-space.element =
element preserve-space {
extension.atts,
global.atts,
(attribute elements { tokens.datatype }
| attribute _elements { avt.datatype })+,
empty
}
decimal-format.element =
element decimal-format {
extension.atts,
global.atts,
attribute name { eqname.datatype }?,
attribute _name { avt.datatype }?,
attribute decimal-separator { char.datatype }?,
attribute _decimal-separator { avt.datatype }?,
attribute grouping-separator { char.datatype }?,
attribute _grouping-separator { avt.datatype }?,
attribute infinity { string.datatype }?,
attribute _infinity { avt.datatype }?,
attribute minus-sign { char.datatype }?,
attribute _minus-sign { avt.datatype }?,
attribute exponent-separator { char.datatype }?,
attribute _exponent-separator { avt.datatype }?,
attribute NaN { string.datatype }?,
attribute _NaN { avt.datatype }?,
attribute percent { char.datatype }?,
attribute _percent { avt.datatype }?,
attribute per-mille { char.datatype }?,
attribute _per-mille { avt.datatype }?,
attribute zero-digit { char.datatype }?,
attribute _zero-digit { avt.datatype }?,
attribute digit { char.datatype }?,
attribute _digit { avt.datatype }?,
attribute pattern-separator { char.datatype }?,
attribute _pattern-separator { avt.datatype }?,
empty
}
template.element =
element template {
extension.atts,
global.atts,
(attribute match { pattern.datatype }
| attribute _match { avt.datatype }
| attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute priority { decimal.datatype }?,
attribute _priority { avt.datatype }?,
attribute mode { list { '#all' | ('#default' | '#unnamed' | eqname.datatype)* } }?,
attribute _mode { avt.datatype }?,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute visibility { "public" | "private" | "final" | "abstract" }?,
attribute _visibility { avt.datatype }?,
(context-item.element?, param.element*, sequence-constructor.model)
}
apply-templates.element =
element apply-templates {
extension.atts,
global.atts,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
attribute mode { (eqname.datatype | '#unnamed' | '#default' | '#current') }?,
attribute _mode { avt.datatype }?,
attribute separator { avt.datatype }?,
attribute _separator { avt.datatype }?,
(sort.element | with-param.element)*
}
mode.element =
element mode {
extension.atts,
global.atts,
attribute name { eqname.datatype }?,
attribute _name { avt.datatype }?,
attribute streamable { boolean.datatype }?,
attribute _streamable { avt.datatype }?,
attribute on-no-match { "deep-copy" | "shallow-copy" | "shallow-copy-all" | "deep-skip" | "shallow-skip" | "text-only-copy" | "fail" }?,
attribute _on-no-match { avt.datatype }?,
attribute on-multiple-match { "use-last" | "fail" }?,
attribute _on-multiple-match { avt.datatype }?,
attribute warning-on-no-match { boolean.datatype }?,
attribute _warning-on-no-match { avt.datatype }?,
attribute warning-on-multiple-match { boolean.datatype }?,
attribute _warning-on-multiple-match { avt.datatype }?,
attribute typed { boolean.datatype | "strict" | "lax" | "unspecified" }?,
attribute _typed { avt.datatype }?,
attribute visibility { "public" | "private" | "final" }?,
attribute _visibility { avt.datatype }?,
attribute use-accumulators { tokens.datatype }?,
attribute _use-accumulators { avt.datatype }?,
empty
}
context-item.element =
element context-item {
extension.atts,
global.atts,
attribute as { item-type.datatype }?,
attribute _as { avt.datatype }?,
attribute use { "required" | "optional" | "absent" }?,
attribute _use { avt.datatype }?,
empty
}
global-context-item.element =
element global-context-item {
extension.atts,
global.atts,
attribute as { item-type.datatype }?,
attribute _as { avt.datatype }?,
attribute use { "required" | "optional" | "absent" }?,
attribute _use { avt.datatype }?,
empty
}
apply-imports.element =
element apply-imports {
extension.atts,
global.atts,
with-param.element*
}
next-match.element =
element next-match {
extension.atts,
global.atts,
(with-param.element | fallback.element)*
}
for-each.element =
element for-each {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
(sort.element*, sequence-constructor.model)
}
iterate.element =
element iterate {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
(param.element*, on-completion.element?, sequence-constructor.model)
}
next-iteration.element =
element next-iteration {
extension.atts,
global.atts,
(with-param.element*)
}
break.element =
element break {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })?,
sequence-constructor.model
}
on-completion.element =
element on-completion {
extension.atts,
global.atts,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
sequence-constructor.model
}
if.element =
element if {
extension.atts,
global.atts,
(attribute test { expression.datatype }
| attribute _test { avt.datatype })+,
sequence-constructor.model
}
choose.element =
element choose {
extension.atts,
global.atts,
(when.element+, otherwise.element?)
}
when.element =
element when {
extension.atts,
global.atts,
(attribute test { expression.datatype }
| attribute _test { avt.datatype })+,
select-or-sequence-constructor.model
}
otherwise.element =
element otherwise {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
switch.element =
element switch {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
(when.element+, otherwise.element?, fallback.element*)
}
try.element =
element try {
extension.atts,
global.atts,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
attribute rollback-output { boolean.datatype }?,
attribute _rollback-output { avt.datatype }?,
(sequence-constructor.model, catch.element, (catch.element | fallback.element)*)
}
catch.element =
element catch {
extension.atts,
global.atts,
attribute errors { tokens.datatype }?,
attribute _errors { avt.datatype }?,
select-or-sequence-constructor.model
}
variable.element =
element variable {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute static { boolean.datatype }?,
attribute _static { avt.datatype }?,
attribute visibility { "public" | "private" | "final" | "abstract" }?,
attribute _visibility { avt.datatype }?,
select-or-sequence-constructor.model
}
param.element =
element param {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute required { boolean.datatype }?,
attribute _required { avt.datatype }?,
attribute tunnel { boolean.datatype }?,
attribute _tunnel { avt.datatype }?,
attribute static { boolean.datatype }?,
attribute _static { avt.datatype }?,
select-or-sequence-constructor.model
}
with-param.element =
element with-param {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute tunnel { boolean.datatype }?,
attribute _tunnel { avt.datatype }?,
select-or-sequence-constructor.model
}
call-template.element =
element call-template {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
with-param.element*
}
attribute-set.element =
element attribute-set {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute use-attribute-sets { eqnames.datatype }?,
attribute _use-attribute-sets { avt.datatype }?,
attribute visibility { "public" | "private" | "final" | "abstract" }?,
attribute _visibility { avt.datatype }?,
attribute streamable { boolean.datatype }?,
attribute _streamable { avt.datatype }?,
attribute.element*
}
function.element =
element function {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute visibility { "public" | "private" | "final" | "abstract" }?,
attribute _visibility { avt.datatype }?,
attribute streamability { "unclassified" | "absorbing" | "inspection" | "filter" | "shallow-descent" | "deep-descent" | "ascent" | eqname.datatype }?,
attribute _streamability { avt.datatype }?,
attribute override-extension-function { boolean.datatype }?,
attribute _override-extension-function { avt.datatype }?,
attribute override { boolean.datatype }?,
attribute _override { avt.datatype }?,
attribute new-each-time { "yes" | "true" | "1" | "no" | "false" | "0" | "maybe" }?,
attribute _new-each-time { avt.datatype }?,
attribute cache { boolean.datatype }?,
attribute _cache { avt.datatype }?,
(param.element*, sequence-constructor.model)
}
evaluate.element =
element evaluate {
extension.atts,
global.atts,
(attribute xpath { expression.datatype }
| attribute _xpath { avt.datatype })+,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute base-uri { uri.datatype | avt.datatype }?,
attribute _base-uri { avt.datatype }?,
attribute with-params { expression.datatype }?,
attribute _with-params { avt.datatype }?,
attribute context-item { expression.datatype }?,
attribute _context-item { avt.datatype }?,
attribute namespace-context { expression.datatype }?,
attribute _namespace-context { avt.datatype }?,
attribute schema-aware { boolean.datatype | avt.datatype }?,
attribute _schema-aware { avt.datatype }?,
(with-param.element | fallback.element)*
}
namespace-alias.element =
element namespace-alias {
extension.atts,
global.atts,
(attribute stylesheet-prefix { prefix.datatype | "#default" }
| attribute _stylesheet-prefix { avt.datatype })+,
(attribute result-prefix { prefix.datatype | "#default" }
| attribute _result-prefix { avt.datatype })+,
empty
}
element.element =
element element {
extension.atts,
global.atts,
(attribute name { qname.datatype | avt.datatype }
| attribute _name { avt.datatype })+,
attribute namespace { uri.datatype | avt.datatype }?,
attribute _namespace { avt.datatype }?,
attribute inherit-namespaces { boolean.datatype }?,
attribute _inherit-namespaces { avt.datatype }?,
attribute use-attribute-sets { eqnames.datatype }?,
attribute _use-attribute-sets { avt.datatype }?,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
sequence-constructor.model
}
attribute.element =
element attribute {
extension.atts,
global.atts,
(attribute name { qname.datatype | avt.datatype }
| attribute _name { avt.datatype })+,
attribute namespace { uri.datatype | avt.datatype }?,
attribute _namespace { avt.datatype }?,
attribute separator { string.datatype | avt.datatype }?,
attribute _separator { avt.datatype }?,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
select-or-sequence-constructor.model
}
text.element =
element text {
extension.atts,
global.atts,
attribute disable-output-escaping { boolean.datatype }?,
attribute _disable-output-escaping { avt.datatype }?,
text
}
value-of.element =
element value-of {
extension.atts,
global.atts,
attribute separator { string.datatype | avt.datatype }?,
attribute _separator { avt.datatype }?,
attribute disable-output-escaping { boolean.datatype }?,
attribute _disable-output-escaping { avt.datatype }?,
select-or-sequence-constructor.model
}
document.element =
element document {
extension.atts,
global.atts,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
sequence-constructor.model
}
processing-instruction.element =
element processing-instruction {
extension.atts,
global.atts,
(attribute name { ncname.datatype | avt.datatype }
| attribute _name { avt.datatype })+,
select-or-sequence-constructor.model
}
namespace.element =
element namespace {
extension.atts,
global.atts,
(attribute name { ncname.datatype | avt.datatype }
| attribute _name { avt.datatype })+,
select-or-sequence-constructor.model
}
comment.element =
element comment {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
copy.element =
element copy {
extension.atts,
global.atts,
attribute copy-namespaces { boolean.datatype }?,
attribute _copy-namespaces { avt.datatype }?,
attribute inherit-namespaces { boolean.datatype }?,
attribute _inherit-namespaces { avt.datatype }?,
attribute use-attribute-sets { eqnames.datatype }?,
attribute _use-attribute-sets { avt.datatype }?,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
sequence-constructor.model
}
copy-of.element =
element copy-of {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
attribute copy-accumulators { boolean.datatype }?,
attribute _copy-accumulators { avt.datatype }?,
attribute copy-namespaces { boolean.datatype }?,
attribute _copy-namespaces { avt.datatype }?,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
empty
}
sequence.element =
element sequence {
extension.atts,
global.atts,
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
select-or-sequence-constructor.model
}
where-populated.element =
element where-populated {
extension.atts,
global.atts,
sequence-constructor.model
}
on-empty.element =
element on-empty {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
on-non-empty.element =
element on-non-empty {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
number.element =
element number {
extension.atts,
global.atts,
attribute value { expression.datatype }?,
attribute _value { avt.datatype }?,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
attribute level { "single" | "multiple" | "any" }?,
attribute _level { avt.datatype }?,
attribute count { pattern.datatype }?,
attribute _count { avt.datatype }?,
attribute from { pattern.datatype }?,
attribute _from { avt.datatype }?,
attribute format { string.datatype | avt.datatype }?,
attribute _format { avt.datatype }?,
attribute lang { language.datatype | avt.datatype }?,
attribute _lang { avt.datatype }?,
attribute letter-value { "alphabetic" | "traditional" | avt.datatype }?,
attribute _letter-value { avt.datatype }?,
attribute ordinal { string.datatype | avt.datatype }?,
attribute _ordinal { avt.datatype }?,
attribute start-at { integer.datatype | avt.datatype }?,
attribute _start-at { avt.datatype }?,
attribute grouping-separator { char.datatype | avt.datatype }?,
attribute _grouping-separator { avt.datatype }?,
attribute grouping-size { integer.datatype | avt.datatype }?,
attribute _grouping-size { avt.datatype }?,
empty
}
sort.element =
element sort {
extension.atts,
global.atts,
attribute lang { language.datatype | avt.datatype }?,
attribute _lang { avt.datatype }?,
attribute order { "ascending" | "descending" | avt.datatype }?,
attribute _order { avt.datatype }?,
attribute collation { uri.datatype | avt.datatype }?,
attribute _collation { avt.datatype }?,
attribute stable { boolean.datatype | avt.datatype }?,
attribute _stable { avt.datatype }?,
attribute case-order { "upper-first" | "lower-first" | avt.datatype }?,
attribute _case-order { avt.datatype }?,
attribute data-type { "text" | "number" | eqname.datatype | avt.datatype }?,
attribute _data-type { avt.datatype }?,
select-or-sequence-constructor.model
}
perform-sort.element =
element perform-sort {
extension.atts,
global.atts,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
(sort.element+, sequence-constructor.model)
}
for-each-group.element =
element for-each-group {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
((attribute group-by { expression.datatype }?,
attribute _group-by { avt.datatype }?) |
(attribute group-adjacent { expression.datatype }?,
attribute _group-adjacent { avt.datatype }?) |
(attribute group-starting-with { pattern.datatype }?,
attribute _group-starting-with { avt.datatype }?) |
(attribute group-ending-with { pattern.datatype }?,
attribute _group-ending-with { avt.datatype }?)),
attribute composite { boolean.datatype }?,
attribute _composite { avt.datatype }?,
attribute collation { uri.datatype | avt.datatype }?,
attribute _collation { avt.datatype }?,
(sort.element*, sequence-constructor.model)
}
merge.element =
element merge {
extension.atts,
global.atts,
(merge-source.element+, merge-action.element, fallback.element*)
}
merge-source.element =
element merge-source {
extension.atts,
global.atts,
attribute name { ncname.datatype }?,
attribute _name { avt.datatype }?,
attribute for-each-item { expression.datatype }?,
attribute _for-each-item { avt.datatype }?,
attribute for-each-stream { expression.datatype }?,
attribute _for-each-stream { avt.datatype }?,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
attribute streamable { boolean.datatype }?,
attribute _streamable { avt.datatype }?,
attribute use-accumulators { tokens.datatype }?,
attribute _use-accumulators { avt.datatype }?,
attribute sort-before-merge { boolean.datatype }?,
attribute _sort-before-merge { avt.datatype }?,
attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }?,
attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?,
attribute for-each-source { expression.datatype }?,
attribute _for-each-source { avt.datatype }?,
merge-key.element+
}
merge-key.element =
element merge-key {
extension.atts,
global.atts,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
attribute lang { language.datatype | avt.datatype }?,
attribute _lang { avt.datatype }?,
attribute order { "ascending" | "descending" | avt.datatype }?,
attribute _order { avt.datatype }?,
attribute collation { uri.datatype | avt.datatype }?,
attribute _collation { avt.datatype }?,
attribute case-order { "upper-first" | "lower-first" | avt.datatype }?,
attribute _case-order { avt.datatype }?,
attribute data-type { "text" | "number" | eqname.datatype | avt.datatype }?,
attribute _data-type { avt.datatype }?,
sequence-constructor.model
}
merge-action.element =
element merge-action {
extension.atts,
global.atts,
sequence-constructor.model
}
fork.element =
element fork {
extension.atts,
global.atts,
(fallback.element*, ((sequence.element, fallback.element*)* | (for-each-group.element, fallback.element*)))
}
analyze-string.element =
element analyze-string {
extension.atts,
global.atts,
(attribute select { expression.datatype }
| attribute _select { avt.datatype })+,
(attribute regex { string.datatype | avt.datatype }
| attribute _regex { avt.datatype })+,
attribute flags { string.datatype | avt.datatype }?,
attribute _flags { avt.datatype }?,
(matching-substring.element?, non-matching-substring.element?, fallback.element*)
}
matching-substring.element =
element matching-substring {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
non-matching-substring.element =
element non-matching-substring {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
source-document.element =
element source-document {
extension.atts,
global.atts,
(attribute href { uri.datatype | avt.datatype }
| attribute _href { avt.datatype })+,
attribute use-accumulators { tokens.datatype }?,
attribute _use-accumulators { avt.datatype }?,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
attribute streamable { boolean.datatype }?,
attribute _streamable { avt.datatype }?,
sequence-constructor.model
}
accumulator.element =
element accumulator {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype }),
(attribute initial-value { expression.datatype }
| attribute _initial-value { avt.datatype }),
attribute as { sequence-type.datatype }?,
attribute _as { avt.datatype }?,
attribute streamable { boolean.datatype }?,
attribute _streamable { avt.datatype }?,
accumulator-rule.element+
}
accumulator-rule.element =
element accumulator-rule {
extension.atts,
global.atts,
(attribute match { pattern.datatype } |
attribute _match { avt.datatype })+,
attribute phase { "start" | "end" }?,
attribute _phase { avt.datatype }?,
select-or-sequence-constructor.model
}
key.element =
element key {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
(attribute match { pattern.datatype }
| attribute _match { avt.datatype })+,
attribute use { expression.datatype }?,
attribute _use { avt.datatype }?,
attribute composite { boolean.datatype }?,
attribute _composite { avt.datatype }?,
attribute collation { uri.datatype }?,
attribute _collation { avt.datatype }?,
sequence-constructor.model
}
map.element =
element map {
extension.atts,
global.atts,
sequence-constructor.model
}
# TODO: add @on-duplicates
# TODO: add @ordering
map-entry.element =
element map-entry {
extension.atts,
global.atts,
(attribute key { expression.datatype }
| attribute _key { avt.datatype }),
select-or-sequence-constructor.model
}
array.element =
element array {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
array-member.element =
element array-member {
extension.atts,
global.atts,
select-or-sequence-constructor.model
}
message.element =
element message {
extension.atts,
global.atts,
attribute terminate { boolean.datatype | avt.datatype }?,
attribute _terminate { avt.datatype }?,
attribute error-code { eqname.datatype | avt.datatype }?,
attribute _error-code { avt.datatype }?,
select-or-sequence-constructor.model
}
assert.element =
element assert {
extension.atts,
global.atts,
(attribute test { expression.datatype }
| attribute _test { avt.datatype })+,
attribute select { expression.datatype }?,
attribute _select { avt.datatype }?,
attribute error-code { eqname.datatype | avt.datatype }?,
attribute _error-code { avt.datatype }?,
sequence-constructor.model
}
fallback.element =
element fallback {
extension.atts,
global.atts,
sequence-constructor.model
}
result-document.element =
element result-document {
extension.atts,
global.atts,
attribute format { eqname.datatype | avt.datatype }?,
attribute _format { avt.datatype }?,
attribute href { uri.datatype | avt.datatype }?,
attribute _href { avt.datatype }?,
((attribute type { eqname.datatype }?,
attribute _type { avt.datatype }?) |
(attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
attribute method { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname.datatype | avt.datatype }?,
attribute _method { avt.datatype }?,
attribute allow-duplicate-names { boolean.datatype | avt.datatype }?,
attribute _allow-duplicate-names { avt.datatype }?,
attribute build-tree { boolean.datatype | avt.datatype }?,
attribute _build-tree { avt.datatype }?,
attribute byte-order-mark { boolean.datatype | avt.datatype }?,
attribute _byte-order-mark { avt.datatype }?,
attribute cdata-section-elements { eqnames.datatype | avt.datatype }?,
attribute _cdata-section-elements { avt.datatype }?,
attribute doctype-public { string.datatype | avt.datatype }?,
attribute _doctype-public { avt.datatype }?,
attribute doctype-system { string.datatype | avt.datatype }?,
attribute _doctype-system { avt.datatype }?,
attribute encoding { string.datatype | avt.datatype }?,
attribute _encoding { avt.datatype }?,
attribute escape-uri-attributes { boolean.datatype | avt.datatype }?,
attribute _escape-uri-attributes { avt.datatype }?,
attribute html-version { decimal.datatype | avt.datatype }?,
attribute _html-version { avt.datatype }?,
attribute include-content-type { boolean.datatype | avt.datatype }?,
attribute _include-content-type { avt.datatype }?,
attribute indent { boolean.datatype | avt.datatype }?,
attribute _indent { avt.datatype }?,
attribute item-separator { string.datatype | avt.datatype }?,
attribute _item-separator { avt.datatype }?,
attribute json-node-output-method { "xml" | "html" | "xhtml" | "text" | eqname.datatype | avt.datatype }?,
attribute _json-node-output-method { avt.datatype }?,
attribute media-type { string.datatype | avt.datatype }?,
attribute _media-type { avt.datatype }?,
attribute normalization-form { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken.datatype | avt.datatype }?,
attribute _normalization-form { avt.datatype }?,
attribute omit-xml-declaration { boolean.datatype | avt.datatype }?,
attribute _omit-xml-declaration { avt.datatype }?,
attribute parameter-document { uri.datatype | avt.datatype }?,
attribute _parameter-document { avt.datatype }?,
attribute standalone { boolean.datatype | "omit" | avt.datatype }?,
attribute _standalone { avt.datatype }?,
attribute suppress-indentation { eqnames.datatype | avt.datatype }?,
attribute _suppress-indentation { avt.datatype }?,
attribute undeclare-prefixes { boolean.datatype | avt.datatype }?,
attribute _undeclare-prefixes { avt.datatype }?,
attribute use-character-maps { eqnames.datatype }?,
attribute _use-character-maps { avt.datatype }?,
attribute output-version { nmtoken.datatype | avt.datatype }?,
attribute _output-version { avt.datatype }?,
sequence-constructor.model
}
output.element =
element output {
extension.atts,
global.atts.except.version,
attribute name { eqname.datatype }?,
attribute _name { avt.datatype }?,
attribute method { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname.datatype }?,
attribute _method { avt.datatype }?,
attribute allow-duplicate-names { boolean.datatype }?,
attribute _allow-duplicate-names { avt.datatype }?,
attribute build-tree { boolean.datatype }?,
attribute _build-tree { avt.datatype }?,
attribute byte-order-mark { boolean.datatype }?,
attribute _byte-order-mark { avt.datatype }?,
attribute cdata-section-elements { eqnames.datatype }?,
attribute _cdata-section-elements { avt.datatype }?,
attribute doctype-public { string.datatype }?,
attribute _doctype-public { avt.datatype }?,
attribute doctype-system { string.datatype }?,
attribute _doctype-system { avt.datatype }?,
attribute encoding { string.datatype }?,
attribute _encoding { avt.datatype }?,
attribute escape-uri-attributes { boolean.datatype }?,
attribute _escape-uri-attributes { avt.datatype }?,
attribute html-version { decimal.datatype }?,
attribute _html-version { avt.datatype }?,
attribute include-content-type { boolean.datatype }?,
attribute _include-content-type { avt.datatype }?,
attribute indent { boolean.datatype }?,
attribute _indent { avt.datatype }?,
attribute item-separator { string.datatype }?,
attribute _item-separator { avt.datatype }?,
attribute json-node-output-method { "xml" | "html" | "xhtml" | "text" | eqname.datatype }?,
attribute _json-node-output-method { avt.datatype }?,
attribute media-type { string.datatype }?,
attribute _media-type { avt.datatype }?,
attribute normalization-form { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken.datatype }?,
attribute _normalization-form { avt.datatype }?,
attribute omit-xml-declaration { boolean.datatype }?,
attribute _omit-xml-declaration { avt.datatype }?,
attribute parameter-document { uri.datatype }?,
attribute _parameter-document { avt.datatype }?,
attribute standalone { boolean.datatype | "omit" }?,
attribute _standalone { avt.datatype }?,
attribute suppress-indentation { eqnames.datatype }?,
attribute _suppress-indentation { avt.datatype }?,
attribute undeclare-prefixes { boolean.datatype }?,
attribute _undeclare-prefixes { avt.datatype }?,
attribute use-character-maps { eqnames.datatype }?,
attribute _use-character-maps { avt.datatype }?,
attribute version { nmtoken.datatype }?,
attribute _version { avt.datatype }?,
empty
}
character-map.element =
element character-map {
extension.atts,
global.atts,
(attribute name { eqname.datatype }
| attribute _name { avt.datatype })+,
attribute use-character-maps { eqnames.datatype }?,
attribute _use-character-maps { avt.datatype }?,
(output-character.element*)
}
output-character.element =
element output-character {
extension.atts,
global.atts,
(attribute character { char.datatype }
| attribute _character { avt.datatype })+,
(attribute string { string.datatype }
| attribute _string { avt.datatype })+,
empty
}
avt.datatype =
xsd:string
# {
# pattern =
# """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*""" # this regexp will not work in all the case.
# }
Use the arrows to browse significant changes since the 3.0 version of this specification.
Sections with significant changes are marked Δ in the table of contents.
Named item types can be declared using the new xsl:item-type element. This is designed to avoid repeating lengthy type definitions (for example function types) every time they are used. [This feature was present in the editor's draft presented to the WG when it started work.]
The xsl:for-each and xsl:apply-templates instructions acquire an attribute separator that can be used to insert content between adjacent items. [This change was in the editor's draft adopted as a baseline when the WG commenced work.]
PR 751 1386
The result type of a mode can be declared using an as attribute. The result type of all template rules in this mode must be consistent with this, as must the values returned by any built-in template rules for the mode.
The xsl:for-each and xsl:apply-templates instructions acquire an attribute separator that can be used to insert content between adjacent items. [This change was in the editor's draft adopted as a baseline when the WG commenced work.]
Numeric values of type xs:decimal are compared as decimals, without first converting to xs:double.
Functions that accept a lexical QName as an argument, such as key, function-available, element-available, type-available, system-property, accumulator-before, and accumulator-after, now have the option of supplying an xs:QName value instead. [This change was in the editor's draft accepted by the WG as its baseline when it started work.]
Functions that accept a lexical QName as an argument, such as key, function-available, element-available, type-available, system-property, accumulator-before, and accumulator-after, now have the option of supplying an xs:QName value instead. [This change was in the editor's draft accepted by the WG as its baseline when it started work.]
It is possible to invoke a named template using an extension instruction, specifically, an element whose name matches the name of the named template.
See 10.1.3 Invoking Named Templates using Extension Instructions
A new attribute xsl:map/@on-duplicates is available, allowing control over how duplicate keys are handled by the xsl:map instruction.
A new attribute xsl:for-each-group/@split-when is available to give applications more complete control over how a sequence is partitioned
See 14 Grouping
Duplicate xsl:include declarations within a stylesheet level are now ignored, preventing spurious errors caused by the presence of duplicate named components.
Named record types are introduced.
The contents of a character map declared using xsl:character-map are now available dynamically via a new character-map function.
New variables err:stack-trace, err:additional, and err:map are available within an xsl:catch clause.
See 8.4 Try/Catch
The input to the serializer can be defined using the select attribute of xsl:result-document as an alternative to using a sequence constructor.
It is no longer an intrinsic error for a global variable to refer to itself; this is now permitted, for example in cases where the value of the global variable is a recursive inline function. Cases where self-reference would not make sense are covered by the existing rules on circularities: see 9.11 Circular Definitions.
The default value for the indent parameter is now defined to be no for all output methods other than html and xhtml.
The xsl:map instruction allows a select attribute as an alternative to the contained sequence constructor.
The xsl:map-entry instruction, in common with other instructions, now raises error XTSE3185 (rather than XTSE3280) if both a select attribute and a sequence constructor are present.
Composite sort keys are allowed in xsl:sort.
PR 159
Parameters on functions declared using xsl:function can now be defined as optional, with a default value supplied.
PR 237
The xsl:if instruction now allows then and else attributes.
See 8.1 Conditional Processing with xsl:if
In xsl:choose, the xsl:when and xsl:otherwise elements can take a select attribute in place of a sequence constructor.
See 8.2 Conditional Processing with xsl:choose
A new xsl:switch instruction is introduced.
PR 326
The higher-order-function feature no longer exists; higher-order functions are now a core part of XSLT, no longer an optional extra.
See 2827 Conformance
PR 353
A new attribute, main-module, is added to the xsl:stylesheet element. The attribute is provided for the benefit of development tools such as syntax-directed editors to provide information about all the components (variables, functions, etc) visible within a stylesheet module.
A new element xsl:note is available for documentation and similar purposes: it can appear anywhere in the stylesheet and is ignored by the XSLT processor.
PR 401
Patterns (especially those used in template rules) can now be defined by reference to item types, so any item type can be used as a match pattern. For example match="record(longitude, latitude, *)" matches any map that includes the key values "longitude" and "latitude".
PR 406
The new instruction xsl:array is introduced to allow construction of arrays.
PR 470
The xsl:stylesheet, xsl:transform, or xsl:package element may have a fixed-namespaces attribute making it easier to have the same namespace declarations in force throughout a stylesheet.
PR 489
The xsl:matching-substring and xsl:non-matching-substring elements within xsl:analyze-string may now take a select attribute in place of a contained sequence constructor.
PR 534
A new serialization parameter escape-solidus is provided to control whether the character / is escaped as \/ by the JSON serialization method.
PR 542
A mode (called an enclosing mode) can be defined in which all the relevant template rules are children of the xsl:mode element. This is intended to allow a stylesheet design in which it is easier to determine which rules might apply to a given xsl:apply-templates call.
PR 599
Simplified stylesheets no longer require an xsl:version attribute (which means they might not need a declaration of the XSLT namespace). Unless otherwise specified, a 4.0 simplified stylesheet defaults expand-text to true.
PR 635
The rules concerning the compatibility of schemas imported by different packages have been clarified. It is now explicitly stated that instructions that trigger validation must use the imported schema of the package in which validation is invoked. This differs from the current practice of some XSLT 3.0 processors, which may use (for example) a schema formed from the union of the imported schemas in all packages.
PR 717
Capturing accumulators have been added; when streaming with a capturing accumulator, the accumulator-after has full access to a snapshot of the matched element node.
PR 718
To allow recursive-descent transformation on a tree of maps and arrays, a new set of built-in templates rules shallow-copy-all is introduced.
PR 751
The xsl:mode declaration acquires an attribute as="sequence-type" which declares the return type of all template rules in that mode.
PR 1181
The [xsl:]xpath-default-namespace attribute can be set to the value ##any, which causes unprefixed element names to match in any namespace or none.
See 5.1.2 Unprefixed Lexical QNames in Expressions and Patterns
PR 1250
The strings used in the formatted number to represent a decimal separator, grouping separator, exponent separator, percent sign, per mille sign, or minus sign, are no longer constrained to be single characters.
PR 1254
The rules concerning the interpretation of xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes have been tightened up.
PR 1306
An as attribute is available on the xsl:sequence instruction.
PR 1361
The term atomic value has been replaced by atomic item.
See 2.1 Terminology
PR 1378
A function call at the outermost level can now be named using any valid EQName (for example fn:doc) provided it binds to one of the permitted functions fn:doc, fn:id, fn:element-with-id, fn:key, or fn:root. If two functions are called, for example doc('a.xml')/id('abc'), it is no longer necessary to put the second call in parentheses.
PR 1442
Default priorities are added for new forms of ElementTest and AttributeTest, for example element(p:*) and element(a|b).
PR 1622
The rules for equality comparison have changed to bring keys into line with maps.
See 20.2.2 fn:key
New in 4.0.
PR 1689
Composite merge keys are now allowed.
See 15 Merging
PR 1703
Ordered maps are introduced.
A number of changes affecting XSLT 4.0 have been made in other related specifications. Some of the more significant changes are as follows:
A number of new kinds of ItemType are introduced, for example choice item types, record types, and enumeration types.
The coercion rules (previously “function conversion rules”) allow atomic items of primitive types to be supplied where a restricted type is required: for example if the required type is xs:positiveInteger, it is now acceptable to supply the value 42.
XPath 4.0 introduces abbreviated syntax for inline functions (for example fn($x, $y) { $x + $y }).
This section lists all known incompatibilities with XSLT 3.0, that is, situations where a stylesheet that is error-free according to the XSLT 3.0 specification and where all elements have an effective version of 3.0 or less, will produce different results depending on whether it is run under an XSLT 3.0 processor or an XSLT 4.0 processor.
The rules for comparing values in xsl:for-each-group now reference the rules for distinct-values, which have themselves changed to be compatible with fn:atomic-equal. This change eliminates the intransitivity in the previous specification, which meant that in edge cases involving rounding of numeric values of different types, two items in different groups could compare equal. Any change in behavior is confined to this edge case.
The rules for comparing values in keys have changed, to align with the rules for maps. The changes affect edge cases involving rounding of numeric values of different types, and the comparison of date/time values with and without timezones.
This specification also corrects a number of errors and omissions in XSLT 3.0, in a way that might create incompatibilities for some processors, depending on how they interpreted the XSLT 3.0 specification:
XSLT 3.0 (and earlier releases) did not fully define the evaluation context for the default values of template parameters. For example, if the default value of a parameter of a template rule invoked xsl:next-match, it was not specified whether the current template rule should be the calling template or the called template. This omission has been corrected.
Where different packages import different schemas, the specification is now more prescriptive about which schema is used for validation. The rules may differ from the conventions adopted by implementations of XSLT 3.0.
XSLT 3.0 failed to specify a default value for the serialization parameter indent where the serialization method is json or adaptive. XSLT 4.0 specifies a default value of no.
See also [XPath 4.0], [Functions and Operators 4.0], and [XSLT and XQuery Serialization 4.0] for incompatibilities in other related specifications that may affect XSLT stylesheets.