[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xslt 3.0, and use of 'as' attribute with xsl:varia

Subject: Re: xslt 3.0, and use of 'as' attribute with xsl:variable
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Aug 2023 16:35:12 -0000
Re:  xslt 3.0
> I think, the XSLT 3.0 variable declaration, <xsl:variable name="var1"
select="'4'" as="xs:integer"/> should work similarly (I think, it should
succeed, and the specific XPath 3.1 function conversion rule seems to me is
wrong if it, disallows this. Apologies to be saying like this, and disagreeing
to the XPath 3.1 spec wrt this point) to what "cast as" expressions as cited
above are able to do.
>
> Any thoughts please?
>

With implicit conversion there is a balance between the early error detection
that you get from strict rules, versus the convenience you get from lax rules.
For 4.0 we have relaxed the rules a little, for example <xsl:variable
select="2" as="xs:positiveInteger"/> will now work.

Note that in XQuery (prior to 4.0), you don't even get atomization in a
variable binding, for example

let $x as xs:string := <a>help</a>

will give you a type error.

To understand these decisions you need a historical and sociological
perspective as well as a purely technical one. XPath 1.0 was completely
dynamically typed, in the tradition of Javascript, while XQuery 1.0 was
designed by people from the database query languages tradition where
optimization is a key driver, and optimization often relies on having accurate
knowledge of static types. So there were some real clashes, and as a result
you get some messy design compromises.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.