- From: Michael Brundage <xquery@comcast.net>
- Date: Tue, 23 Sep 2003 21:56:35 -0700
- To: "'Jan Hidders'" <jan.hidders@ua.ac.be>, <www-ql@w3.org>
The data model defines three concepts: documents, fragments, and sequences. You're mixing up the latter two. (There is no such thing as "sibling order".) A document is a rooted hierarchy of nodes, in which the root node kind is "document node". A fragment is a rooted hierarchy of nodes, in which the root node kind is any other kind. Every node (whether selected or constructed) belongs to a unique fragment or document. Every node in a document or fragment has a unique identity. A sequence is an ordered (flat) collection (which may contain nodes or values). A sequence may contain the same node (by identity) any number of times. There is a binary relation that goes by the misnomer "document order", that is defined for every pair of nodes (whether from the same document, fragment, or not). This relation is defined so that it corresponds to left-depth-first traversal order for two nodes within the same document or fragment. For two nodes in different fragments or documents, the relation is non-deterministic ("implementation dependent") but constant within the execution of a single query ("stable"). The order of items within a sequence has nothing to do with "document order" and vice-versa. The only time the two concepts interact at all are: - The children of a node is a *sequence* of nodes, such that the sequence order matches their document order ($a is before $b in the sequence iff $a is before $b in document order). - More generally, every path expression returns a sequence of nodes ordered so that the sequence order corresponds to document order. The examples I gave below attempt to illustrate these principles. The expression <x><y/><y/></x> constructs a fragment containing three nodes: an x element, with 2 y element children. The *document order* of any two of these is defined by XQuery. The expression (<x><y/><y/></x>)/y selects a *sequence* of nodes (the children of x), sorted in *document order*. The expression (<x><y/><y/></x>)/y[1] picks the first one from that sequence in *sequence order*. The expression (<x><y/><y/></x>)/y[2] picks the second one in *sequence order*. The << operator compares them in *document order* and returns true. In contrast, the expression (<y/>, <y/>) constructs two fragments, each containing a single node. The *document order* of these two nodes is implementation-dependent. (The *sequence order* is defined by XQuery.) The expression (<y/>, <y/>)[1] picks the first of these nodes in *sequence order*. The expression (<y/>, <y/>)[2] picks the second of these in *sequence order*. The << operator compares them in *document order*, and returns the implementation-dependent value. -----Original Message----- From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf Of Jan Hidders Sent: Tuesday, September 23, 2003 4:32 PM To: www-ql@w3.org Subject: Re: creation order vs. document order On Tuesday 23 September 2003 23:54, Michael Rys wrote: > What Michael points out is that there are two notions of orders for > nodes. I'm not sure I understand your point. I know that is what he was trying to point out and I believe I already made clear that I already knew that by asking the follow-up questions that I asked. My comment was that the example that he gave: >> let $tree1 := (<x><y/><y/></x>)/y >> return $tree1[1] << $tree1[2] does not demonstrate that the sibling-order of the two y elements is equal to their document order. Perhaps I'm misunderstanding what he wants to make clear with the example, but otherwise I don't see the point of it. Anyway, I still would like to know if it is possible for child nodes in a fragment that is not in a document to have a sibling-order that is different from the document order. Right now the formal semantics seem to say that it can. That surprises me. -- Jan Hidders
Received on Wednesday, 24 September 2003 00:49:48 UTC