With regard to XSLT as query language three pieces are missing.
XSLT 2.0 introduced the capability to declare the required types of, among other things, variables. The type can be a built-in or a user-defined type imported from an XML schema. Schematron is currently missing both: The possibility to declare the required type of a variable and to import user-defined data types.
XSLT 3.0 added accumulators as a new mechanism to capture and process data. An
accumulator associates a series of values with nodes of the document tree. The value
of an accumulator is obtained by calling the respective accumulator functions
fn:accumulator-before()
and
fn:accumulator-after()
. Although accumulators are designed
for streaming transformations they can also be used with non-streaming
transformations.
The addition of user-defined functions in XSLT 2.0 opened up the possibility of reusable, user-defined function libraries. XSLT 3.0 made the notion of user-defined libraries explicit by adding packages, collections of stylesheet modules with a controlled interface.
Schematron lacks a way of including user-defined function libraries other than
using schema composition instructions. But neither sch:include
nor sch:extends
is a good fit. The
former inserts the content of an XML document in place of the element, the latter is
only allowed to extend a rule. [2]
To address these missing pieces the query language specification for XSLT should be expanded as follows:
allow xsl:include
and xsl:import
as top-level elements for the query languages XSLT 1.0, 2.0, and
3.0
allow xsl:schema-import
as top-level elements for the
query languages XSLT 2.0 and 3.0
allow an optional as
attribute on a sch:let
instruction
allow xsl:use-package
and xsl:accumulator
as top-level elements for the query language XSLT 3.0
Table 2. Query language environment for XSLT (proposed additions marked with an asterisk)
XSLT 1.0 | XSLT 2.0 | XSLT 3.0 | |
---|---|---|---|
Indexes | xsl:key | xsl:key | xsl:key |
Functions | - | xsl:function | xsl:function |
Namespaces | sch:ns | sch:ns | sch:ns |
Variables | sch:let | sch:let | sch:let |
User-defined libraries* | xsl:include , xsl:import | xsl:include , xsl:import | xsl:include , xsl:import , xsl:use-package |
Typed variables* | - | sch:let /as | sch:let /as |
User-defined types* | - | sch:import-schema | sch:import-schema |
Accumulators* | - | - | xsl:accumulator |