Project

Profile

Help

XQuery union operation

Added by Anonymous over 19 years ago

Legacy ID: #2977514 Legacy Poster: amitabh ojha (amitabhojha)

I invite your attention to the following queries and results thereof (expressed as a sequence here), as returned by saxon7.jar :- Query 1 (<item>a</item>) union (<item>a</item>) Result 1 (<item>a</item>, <item>a</item>) Query 2 let $a := <item>a</item> return $a union $a Result 2 (<item>a</item>) Query 3 (<item>a</item>, <item>b</item>) union (<item>b</item>, <item>c</item>) Result 3 (<item>a</item>, <item>b</item>, <item>b</item>, <item>c</item>) Query 4 let $a := <item>a</item> let $b := <item>b</item> let $c := <item>c</item> return ($a, $b) union ($b, $c) Result 4 (<item>a</item>, <item>b</item>, <item>c</item>) Since I am conceptually not so clear about XQuery union operation, I will be very grateful if you would kindly confirm to me if the above results, as returned by saxon7.jar are all consistent with the XQuery rules. Thanks. Amitabh Ojha


Replies (1)

RE: XQuery union operation - Added by Anonymous over 19 years ago

Legacy ID: #2979234 Legacy Poster: Michael Kay (mhkay)

Yes, these results are all correct. Please note though that saxon7.jar suggests you're using an old version. I think the concept you are missing is that union eliminates nodes with the same identity. It's nothing to do with the node's content. A node acquires its identity at the moment it is created, and if two nodes are created by evaluating different expressions, or by different evaluations of the same expression, then they have different identity even if they have the same name and string-value. Michael Kay

    (1-1/1)

    Please register to reply