Hi Hans-Jürgen,
for $node at $pos in doc('otds-fti')/foo/bar/document{.} return ...
So the final step /document{.}
turns the for loop into caching.
A minor thing I'd like to add:
* The semantics of the path expression is that all results need to be returned in "document order". * Document order is well-defined within a single document. However, it is implementation-defined when working across multiple documents. * As a result, the following query...
let $doc1 := document { 'a' } let $doc2 := document { 'a' } return ($doc1, $doc2)/self::node()
…may either return doc1 or doc2 as first result.
The nodes won't be reordered with the simple map operator:
for $node at $pos in doc('otds-fti')/foo/bar ! document{.}
Cheers, Christian