[xquery-talk] some ... satisfies with positional variable
linse at cip.ifi.lmu.de
Fri Aug 19 22:21:57 PDT 2005
Here's a question about an XQuery language construct I would appreciate.
in for-clauses it is possible to include a positional variable and return
the context node $fs:dot - or any other node - based on the position of
its child elements.
for $x at $pos in child::tag0 return
if ($pos > 3) then return $fs:dot
If the context node has more than 4 children, the above expression will
return it more than once. This could be avoided by wrapping the result in
a distinct-doc-order function, but it wouldn't prevent the compiler from
executing extra work, does it?
Without positional variables extra work can be evaded by using the some
... satisfies ... clause:
if (some $x in child::* satisfies (fn:node-name($x) == "tag2")))
This works fine, but I cannot include a positional variable in the
conditional. What I need is a "some ... at ... in ... satisfies ... "
construct similar to the following:
if (some $x at $pos in child::* satisfies ($pos > 3))
But this is not provided by XQuery. XPath expressions won't help since
they're normalized to for, if-clauses, etc.
Is there a special reason why a "some ... at ... in ... satisfies ..."
construct is not provided by XQuery?
Is there any possibility to express expr1 in a way that no duplicate
elements are returned?
More information about the talk