[xquery-talk] strange behaviour of XQuery
John Snelson
john.snelson at marklogic.com
Thu Jun 20 08:08:06 PDT 2013
Comparison under the default collation is simple codepoint-wise
lexicographical comparison.
John
On 20/06/13 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
> <gkholman at cranesoftwrights.com <mailto:gkholman at cranesoftwrights.com>>
> 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
> <http://www.CraneSoftwrights.com/links/udemy.htm> |
> Crane Softwrights Ltd. http://www.CraneSoftwrights.__com/q/
> <http://www.CraneSoftwrights.com/q/> |
> G. Ken Holman
> mailto:gkholman at __CraneSoftwrights.com
> <mailto:gkholman at CraneSoftwrights.com> |
> Google+ profile:
> https://plus.google.com/__116832879756988317389/about
> <https://plus.google.com/116832879756988317389/about> |
> Legal business disclaimers: http://www.CraneSoftwrights.__com/legal
> <http://www.CraneSoftwrights.com/legal> |
>
> _________________________________________________
> talk at x-query.com <mailto:talk at x-query.com>
> http://x-query.com/mailman/__listinfo/talk
> <http://x-query.com/mailman/listinfo/talk>
>
>
>
>
> --
> *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