[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: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 29 Jul 2015 20:49:16 -0000

> 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