Closed dmj closed 5 months ago
Just to add here: as mentioned in my paper at Markup UK 2023, this makes a lot of sense and is overdue.
It removes the need for the processor try and infer datatype from value
(and even allows it to check the datatype supplied by @as
, e.g. using instance of
).
Definitely needed.
@as defined in base Schematron. Annex for each QLB defines which production to use.
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/