Re: creation order vs. document order


On September 23 (15:35 +0200), Jan Hidders wrote with possible deletions:
| [...]
|    for $a in $list1
|    for $b in $list2
|    where $a/name = $b/name
|    return <c> $a, $b </c>
| Must the result of this always be a list that is sorted in document
| order? Intuitively I would expect them to be sorted in the order in
| which they were created, but as far as I can tell the formal semantics
| leaves this unspecified.

Your expectation is met: the resulting list of <c> elements is in
creation order as you name it.  Document order sorted node lists are
created when XPath location steps are applied to a given (however
sorted) sequence of context nodes.  This does not apply for your
example, however.

My students stumble about the distinction all the time:


is not equivalent to

                 for $n in $list
                    return $n/axis::nodetest

Best wishes,

  | Dr. Torsten Grust                 |
  |                          |
  | Database Research Group, University of Konstanz (Lake Constance/Germany) |
  |             (Please avoid sending me MS Word or PowerPoint attachments.) |

Received on Tuesday, 23 September 2003 09:41:11 UTC