Re: [xsl] [XSL 3.0] Function that check if a xs:string can be converted as a xs:double

Subject: Re: [xsl] [XSL 3.0] Function that check if a xs:string can be converted as a xs:double
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 May 2023 15:57:28 -0000
> I think it was Ken H who once suggested (context of XSLT 1.0)
select="number($str) = number($str)" as NaN is not equal to itself. I can't
say where he got it. (In XPath 1.0 one was forced to be creative.) Or whether
it would work for you in the given context or indeed corresponds to 'castable
as'.
>

Testing whether the result of number($str) is NaN is usually the same as
testing whether $str is castable to xs:double, but there is at least one case
when it's different, namely when $str is the string "NaN".

Michael Kay
Saxonica

Current Thread