In the first query, 10000 < 100000 is true whether you compare as strings or as 
numbers.

Michael Kay
Saxonica

On 20 Jun 2013, at 16:05, Kunal Chauhan wrote:

> Ken , John you are right.
> If we compare any two untyped value in XQuery, it will treated as string.
> but Still if we compare string length wise or something, in that case also it 
> should give false result for query 2.
> and why I am getting right ans for query 1 ?
> 
> it would be good and helpful for me if any one can tell me on what basis the 
> comparison done ?
> 
> Thanks,
> 
> 
> On Thu, Jun 20, 2013 at 8:18 PM, G. Ken Holman 
> <[email protected]> wrote:
> 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:[email protected] |
> Google+ profile: https://plus.google.com/116832879756988317389/about |
> Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |
> 
> _______________________________________________
> [email protected]
> http://x-query.com/mailman/listinfo/talk
> 
> 
> 
> -- 
> Kunal Chauhan
> [email protected]
> [+918655517141]
> _______________________________________________
> [email protected]
> http://x-query.com/mailman/listinfo/talk

_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to