[xquery-talk] arrow operator

Michael Kay mike at saxonica.com
Wed Aug 2 04:31:37 PDT 2017


There are even good reasons for replacing
> / with !, e.g. if you do not want to have duplicate-free and ordered
> results.
> 

Yes, I'm advising people to do that, especially after a variable reference as in 

for ... return $x/item

which hardly ever needs a sort into document order so it's better to write $x!item.

I had a case reported to me recently where $var was a sequence of three parentless element nodes and $var / item essentially randomized the order because the relative order of nodes in different trees is undefined. Much better to write $var ! item which (a) makes the result predictable, and (b) avoids the cost of an unwanted sort.

Michael Kay
Saxonica




More information about the talk mailing list