Typed variables #1
Labels
2025
A change made in preparing the 2025 edition
implemented
Implemented enhancement
proposed
Proposed enhancement
The current specification of Schematron does not provide means to declare the required type of a variable. Users of Schematron are working around this shortcoming by defining variables using the xsl:variable instruction and relying on the underlying processor to copy these variable declarations to the validation stylesheet.
This document proposes the use of a single @as attribute on a Schematron variable declaration to indicate the required type of a variable for query languages that support typed variables.
For the XSLT 2.0 and the XSLT 3.0 query binding this attribute has the same semantics as described in section 9.3 of [XSLT2] and [XSLT3] respectively.
Caveat: Declaring the type of a variable can change the result of an XPath expression. For example, in XSLT 2.0 and XSLT 3.0 a variable declared to be a sequence of elements behaves differently than the same variable without a type declaration. The latter case creates an implicit document node, while the former does not.
[XSLT2] : XSL Transformations (XSLT) Version 2.0 (Second Edition), http://www.w3.org/TR/xslt20/
[XSLT3] : XSL Transformations (XSLT) Version 3.0, https://www.w3.org/TR/xslt-30/
The text was updated successfully, but these errors were encountered: