[XQuery] 3.2 Order of nodes constructed in a path

Currently the order of nodes constructed in a path is undefined for 
many cases. For example:

let $source := <foo><a>1<a>2</a></a><a>3</a></foo>
return $source/element bar { .//a/element b { text() } }

will return a variation of <bar><b>1</b><b>3</b><b>2</b></bar> with the 
"b" elements in an undefined, but stable, order. From 2.3.1 Document 
Order: "The relative order of nodes in distinct trees is stable but 
implementation-dependent, subject to the following constraint: If any 
node in tree T1 is before any node in tree T2, then all nodes in tree 
T1 are before all nodes in tree T2."

We feel this is unsatisfactory for embedded node creation; the order of 
created elements should be the same across implementations (and runs on 
the same implementation). One simple fix is to base the document order 
of new nodes in a path on their position. However, this brings up 
problems where the position repeats. For example:

let $source :=
<source>
	<foo><a>1<a>2</a></a><a>3</a></foo>
	<foo><a>4<a>5</a></a><a>6</a></foo>
</source>
return $source/element bar { .//a/element b { text() } }

Would end up with nodes 1 and 4 appearing before elements 2 and 5. We 
would appreciate any input on this issue.

--Sarah

Received on Wednesday, 4 February 2004 16:13:31 UTC