[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    Re: [xsl] xslt 3.0, and use of 'as' attribute with xsl:variable
From:       "Graydon graydon () marost ! ca" <xsl-list-service () lists ! mulberrytech ! com>
Date:       2023-09-02 3:38:45
Message-ID: 20230901233806.90474e02 () lists ! mulberrytech ! com
[Download RAW message or body]

On Fri, Sep 01, 2023 at 05:07:19PM -0000, Liam R. E. Quin
liam@fromoldbooks.org scripsit:
> On Fri, 2023-09-01 at 08:14 +0000, Mukul Gandhi
> mukulg@softwarebytes.org wrote:
>> As I've mentioned within another mail on this thread, I think XPath
>> 3.1 function conversion rules prohibiting a string value '4' to be
>> cast to an xs:integer type is not very much right.
> 
> Actually it's *exactly* what i want. 

I might phrase this as not expecting the processor to read my mind; I
know it can't do that reliably, and the cases where it fails are likely
to be more important than those where it succeeds.

Phrasing aside, I want strong typing too.

> If i provide a string where a number is expected yes please give me an
> error. The point of using as= is not only optimization and
> performance, but also detecting mistakes at compile time, so i don't
> get a surprise three years from now in production when a rarely-used
> codepath is exercised.

It took me some time to get used to having to explicitly cast everything
in XQuery, but telling the processor the expected type and number really
has made it easier to get the expected result in XSLT.


-- 
Graydon Saunders  | graydonish@fastmail.com
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/651070
or by email: xsl-list-unsub@lists.mulberrytech.com
--~--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic