Given those truths ...
If you do have a sequence from fn:collection() or another function you *can*
find the position of a document in that collection and its 'sibling'
Note: this may be a horribly inefficient thing to do so buyer beware ....
let $c := fn:collection(),
$doc := local:pick-a-random-doc( $c ),
$prev := $c[ fn:index-of( $c , $doc ) - 1 ] (: Might be bad to do on the
first or only document :)
return $c
this will answer the question of "what is the previous document in the sequence
provided by fn:collection() ...
( you can replace fn:collection() with any function that produces a sequence of
documents )
----------------------------------------
David A. Lee
[email protected]
http://www.xmlsh.org
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Michael Kay
Sent: Sunday, January 05, 2014 3:54 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [xquery-talk] Collections - family relationships
On 5 Jan 2014, at 16:50, Ihe Onwuka <[email protected]> wrote:
> If x is the document element of a document in a collection, is it the sibling
> of y that is the document element of another document in the same collection?
No.
>
> If not why not?
"Why" questions are very difficult to answer. Do you want a historically
accurate answer (was the question debated at a WG meeting, who argued which
position, how did the vote go, and why did individual members vote as they
did?) - because it's very rarely possible to give one. Or do you want a
post-hoc justification (can you think of a sensible reason that anyone might
have designed it this way?)
One post-hoc justification is that collections are unordered, whereas axes are
always ordered.
Another is that documents may belong to more than one collection.
Michael Kay
Saxonica
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk