[xquery-talk] Collections - family relationships
David Lee
dlee at calldei.com
Sun Jan 5 12:59:58 PST 2014
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
dlee at calldei.com
http://www.xmlsh.org
-----Original Message-----
From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Michael Kay
Sent: Sunday, January 05, 2014 3:54 PM
To: ihe.onwuka at gmail.com
Cc: talk at x-query.com
Subject: Re: [xquery-talk] Collections - family relationships
On 5 Jan 2014, at 16:50, Ihe Onwuka <ihe.onwuka at gmail.com> 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
_______________________________________________
talk at x-query.com
http://x-query.com/mailman/listinfo/talk
More information about the talk
mailing list