[xquery-talk] strange behaviour of XQuery

John Snelson john.snelson at marklogic.com
Thu Jun 20 07:50:40 PDT 2013


The comparisons of element values are being done with string semantics. 
With untyped XML you should cast to a numeric type to reliably get 
numeric comparisons.

John

On 20/06/13 15:46, Kunal Chauhan wrote:
> Hello All,
>
> I run some sample XQuery. and it gives me very strange answer.
> Following are my Query with the result.
>
> Query 1 :
>
> let $a := <a>10000</a>
> let $b := <b>100000</b>
>
> return $a >= $b
>
> Output : false
>
>
> Query 2 :
>
> let $a := <a>50000</a>
> let $b := <b>100000</b>
>
> return $a >= $b
>
> Output : true
>
>
> Query 3 :
>
> let $a := 50000
> let $b := 100000
>
> return $a >= $b
>
> Output : false
>
> I am surprised with output of query 2. when I remove node and make it
> value it gives proper output.
>
> can anyone tell me why it's behave lilke this way.
>
> Regards,
>
> --
> *Kunal Chauhan*
> mail4ck at gmail.com <mailto:mail4ck at gmail.com>
> [+918655517141]
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>


-- 
John Snelson, Lead Engineer                    http://twitter.com/jpcs
MarkLogic Corporation                         http://www.marklogic.com


More information about the talk mailing list