[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Cannot compare xs:untypedAtomic to xs:double


Subject: Re: [xsl] Cannot compare xs:untypedAtomic to xs:double
From: "Jorge . chocolate.camera@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 30 Jul 2015 09:52:40 -0000

I was not aware of the difference between lt and &lt;. The latter does
indeed allow me to bypass converting referenced node attribute values
to double. I see that it is explained in the spec for XPath 2.0 >
3.5.2 General Comparisons
(http://www.w3.org/TR/xpath20/#id-general-comparisons).

In what case one might prefer lt to &lt;? When one wants to enforce
error checking in case of potential unexpected values, for instance?

On Wed, Jul 29, 2015 at 10:49 PM, Michael Kay mike@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> On 29 Jul 2015, at 19:54, Jorge . chocolate.camera@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> When comparing numeric values of node attributes to a double, I have
>> to explicitly convert those attribute values too into a double or else
>> Saxon complains that I cannot compare an untyped value to a double.
>
> Saxon of course is only doing what the XSLT 2.0 specification requiresb&.
>
> The general comparison operators like b<b (unlike bltb) convert an
untyped operand to the type of the other operand. This is often handy, but it
does make optimization more difficult (for example, Saxon-EE isnbt able to
use hashing and indexing unless it can infer the types of the operands
statically).
>
>>
>> Considering that the input tree actually is generated some steps above
>> via an identity copy and stored into a variable, is there a way to
>> create it so that Saxon does know that those attribute values are
>> doubles
>
> Yes, you can make the stylesheet schema-aware, in which case the numeric
attributes will be labelled as numeric rather than being untyped.
>
> Michael Kay
> Saxonica


Current Thread
Keywords