Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed variables #1

Closed
dmj opened this issue Mar 31, 2020 · 2 comments
Closed

Typed variables #1

dmj opened this issue Mar 31, 2020 · 2 comments
Labels
2025 A change made in preparing the 2025 edition implemented Implemented enhancement proposed Proposed enhancement

Comments

@dmj
Copy link
Member

dmj commented Mar 31, 2020

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/

@AndrewSales
Copy link
Collaborator

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).

@AndrewSales AndrewSales added the 2025 A change made in preparing the 2025 edition label Feb 11, 2024
AndrewSales added a commit to Schematron/schema that referenced this issue Feb 11, 2024
@rjelliffe
Copy link
Member

Definitely needed.

@as defined in base Schematron. Annex for each QLB defines which production to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2025 A change made in preparing the 2025 edition implemented Implemented enhancement proposed Proposed enhancement
Projects
None yet
Development

No branches or pull requests

3 participants