J Changes since XSLT 2.0 (Non-Normative)

J.1 Changes in this Specification

  1. A stylesheet may now consist of multiple packages. The language specification for packages has been designed with a view to allowing packages to be compiled independently of each other. The specification provides control over the interface offered by a package to other packages; in particular it allows functions, variables, named templates and other components to be declared as public, private, final, or abstract.

  2. A new xsl:mode declaration is added.

    1. A mode may be declared to be streamable, and rules are given that constrain what the template rules in a streamable mode can do.

    2. An xsl:mode declaration may define the action to be taken when there is no matching template rule, and the action to be taken when there are multiple matching template rules.

    3. An xsl:mode declaration may indicate that the template rules in a given mode are designed to process typed (schema-validated) nodes only, or untyped nodes only. It may also indicate that element names appearing in match patterns for the mode are only to match elements in the source document that have been validated against the corresponding element declarations in the schema.

    4. A default mode can be declared for a stylesheet module, making it easier to reuse existing stylesheet modules to construct a composite stylesheet.

  3. Several new instructions are introduced with the aim of making it easier to write streamable transformations, although all of these instructions can also be used without streaming:

    1. The xsl:source-document instruction is provided to read and process an input document using streaming.

    2. The xsl:iterate instruction allows iterative processing of a sequence, with the ability for the processing of one item to depend on the results of processing of previous items, and with the ability to terminate the iteration before all the items in the sequence have been processed.

    3. The xsl:merge instruction allows several input sequences to be merged into a single output sequence, based on the value of a merge key.

    4. The xsl:fork instruction allows multiple results to be computed during a single pass of a streamed input document.

      The xsl:sequence instruction can now contain a sequence constructor as an alternative to using the select attribute. This is primarily for use cases involving xsl:fork.

    5. New instructions xsl:where-populated, xsl:on-empty, and xsl:on-non-empty are introduced to allow elements to be generated only when relevant content exists (or does not exist), without requiring the input to be processed more than once.

  4. Other changes introduced to facilitate the writing of streamable transformations include:

    1. The new top-level declaration xsl:accumulator is introduced. An accumulator represents information about a node in a document that can be computed during a streamed pass over the document, starting at the start and ending at that node.

    2. New functions copy-of and snapshot are provided, to enable streaming applications to operate in windowing mode, where the input document is divided into a sequence of small subtrees processed one at a time.

  5. Some further new instructions are provided, unrelated to streaming:

    1. The xsl:try instruction allows recovery from dynamic errors.

    2. A new xsl:evaluate instruction is provided, to allow evaluation of XPath expressions constructed dynamically from strings, or read from a source document.

    3. The xsl:assert instruction allows arbitrary assertions about the state of variables or the input document, improving testability and robustness.

  6. Static global variables and parameters can be declared. These act as compile-time constants. The values of static variables can be used in initializing other static variables, or in [xsl:]use-when attributes, or in shadow attributes. Shadow attributes allow any attribute of an XSLT instruction or declaration to be parameterized by reference to static variables and parameters.

  7. Text nodes within a sequence constructor may now contain text value templates (XPath expressions enclosed in curly brackets), if this is enabled by setting expand-text="yes"> on an enclosing element. This reduces the verbosity of code written to generate boilerplate text with variable inserts.

  8. The syntax of patterns has been generalized. Patterns may now match any item (not only nodes). In consequence, xsl:apply-templates can now process sequences of atomic values as well as nodes, and xsl:for-each-group with the group-starting-with and group-ending-with options can also process atomic sequences. As a further consequence, the items in the initial match selection supplied when initiating a transformation are no longer required to be nodes.

  9. A new datatype, called a map, has been introduced, together with supporting functions, operators, and type syntax. Maps allow more complex data structures to be created than is possible using atomic values and nodes alone. This has particular applications to streamed processing: since a streamed application can visit each node of its primary input document only once, it often needs more advanced data structures to retain what it has already seen in the document.

  10. Miscellaneous changes to existing instructions and declarations include:

    1. The regular expression supplied to the xsl:analyze-string instruction is now permitted to be one that matches a zero-length string.

    2. The xsl:copy instruction now has a select attribute, which is convenient when it is used inside a function where there is no context item.

    3. Composite keys are supported in xsl:for-each-group.

    4. Two new attributes have been added to xsl:function to provide increased scope for optimization: new-each-time and cache. The first indicates whether the identity of nodes created by the function is significant to the application; the second indicates whether the function is to cache its results (memoization).

    5. The override attribute of xsl:function is renamed override-extension-function, retaining the old name as a deprecated synonym.

    6. The rule requiring xsl:import declarations to precede all other declarations in a stylesheet module has been removed.

    7. Composite keys are supported in xsl:key.

    8. A new attribute on xsl:message allows specification of an error code.

    9. The rules for handling conflicts between xsl:strip-space and xsl:preserve-space have changed. A conflict that can be detected statically is now signaled as a static error; a run-time conflict between two declarations having the same precedence and priority is now resolved by taking whichever comes last in declaration order.

    10. An xsl:template declaration may contain an xsl:context-item element to declare the required type of the context item when the template is called.

    11. An empty xsl:value-of instruction with no select attribute is now permitted; its effect is to construct a zero-length text node.

    12. The xsl:variable and xsl:param elements may now specify static="yes", denoting that the variable is available statically (informally, “at compile time”). Static variables and parameters make the [xsl:]use-when mechanism more useful, especially in conjunction with xsl:assert.

  11. New functions are available to import and export data in JSON format.

  12. A basic XSLT Processor now recognizes all the built-in types defined in XML Schema.

  13. A basic XSLT Processor will now accept the attribute validation="lax" and interpret it in the same way as a schema-aware processor when there is no schema component available to perform the validation.

  14. Some functions, including generate-idFO30, format-dateFO30, format-dateTimeFO30, format-numberFO30, format-timeFO30, and unparsed-textFO30 have been moved from this specification to the Functions and Operators specification, to make them available in other host languages.

  15. The rule that effectively prevented references to external documents in [xsl:]use-when expressions has been removed.

  16. A default value is defined for the named template to be used when initiating a transformation (specifically, xsl:initial-template).

  17. Serialization to HTML5 and XHTML5 is supported. To this end, a new serialization parameter html-version is provided in xsl:output and xsl:result-document.

    Other new serialization parameters include: item-separator, json-node-output-method, parameter-document, suppress-indentation.

  18. The concept of recoverable dynamic errors has been dropped. Of the remaining recoverable dynamic errors, some are no longer errors, and others are now situations where the behavior of the processor is implementation-dependent. The adjective non-recoverable in describing other dynamic errors becomes redundant and has therefore been dropped (the term was in any case misleading since the introduction of a try/catch mechanism). Error codes of the form XTREnnnn have been renumbered XTDEnnnn.

    Dynamic errors occurring during pattern evaluation are always masked (they cause the pattern to report a non-match.)

  19. A family of collation URIs is defined for selecting collations based on the Unicode Collation Algorithm.

  20. The effect of specifying the type xs:untyped or xs:untypedAtomic when validating by type is now defined.

  21. The set of constructs that set temporary output state has been reduced, and no longer includes instructions that create nodes, such as xsl:attribute and xsl:value-of. However, xsl:merge-key has been added to the list.

  22. The possibilities for invocation of a stylesheet have been expanded; they now include the ability to directly execute a stylesheet function; to supply parameters to the initial template; and to return the results of the invoked template or function as a raw value, without construction of a result tree.

J.2 Changes in Other Related Specifications

A number of changes affecting XSLT 3.0 have been made in other related specifications. Some of the more significant changes are as follows:

  1. A number of new functions have been defined whose aim is to facilitate streaming. These include unparsed-text-linesFO30, innermostFO30, outermostFO30.

  2. XPath 3.0 supports a subset of the let expression from XQuery.

  3. XPath 3.0 supports function items as first-class values (functions can, for example, be bound to variables and passed as parameters to other functions.)

  4. XPath 3.0 supports a new syntax for writing expanded names using the namespace URI and local part only, avoiding the need to create a static context that binds namespace prefixes. This is intended to be particularly useful when XPath expressions are software-generated. Complementing this, a new function pathFO30 is available to generate a (namespace-context-independent) path to any node that can subsequently be evaluated using the xsl:evaluate instruction, or otherwise.