[xquery-talk] strange behaviour of XQuery

G. Ken Holman gkholman at CraneSoftwrights.com
Thu Jun 20 07:48:59 PDT 2013


At 2013-06-20 20:16 +0530, 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.

In the absence of a schema declaring that <a> and <b> are numbers, 
the values are considered to be text strings.  In your third example, 
the values are not nodes but are numbers by the syntax you've used, 
so you get what you expect.

I hope this helps.

. . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/q/ |
G. Ken Holman                   mailto:gkholman at CraneSoftwrights.com |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |



More information about the talk mailing list