Project

Profile

Help

XQuery: nested constructors - a bug?

Added by Anonymous over 19 years ago

Legacy ID: #3072192 Legacy Poster: p-h7 (p-h7)

Hi, I've been experimenting with saxon 8.3 (free version) and it seems to me that I've found a bug. This is connected to i) semantics of a step expression that should return elements in document order, ii) nested constructors that should create nodes with new node identities (and I think even document order) when new nodes are constructed in them. I use an xml file with 'author' elements, where each author has her lastname in 'last' element. Running the following query I get the last names sorted well. <some>{ for $a in //author order by $a/last return $a }</some>)//last While running the following query, the last names are in document order. ( for $a in //author order by $a/last return <some>{$a}</some> )//last It is not clear to me whether it is a bug or a correct behaviour. I've checked both XQuery 1.0 and XQuery 1.0 and XPath 2.0 Formal Semantics and was not able to find the answer. Thanks for help. Pavel


Replies (2)

RE: XQuery: nested constructors - a bug? - Added by Anonymous over 19 years ago

Legacy ID: #3072546 Legacy Poster: Michael Kay (mhkay)

Let's use this source document: <a> <author><last>Smith</last></author> <author><last>Jones</last></author> <author><last>Evans</last></author> <author><last>Hardy</last></author> </a> With the first query, the answer is: <?xml version="1.0" encoding="UTF-8"?> <last>Evans</last> <last>Hardy</last> <last>Jones</last> <last>Smith</last> which is correct: the query has created a <some> element whose children are the sorted list of authors, it then extracts the authors in document order. Document order is the order of the children, which is sorted order because that's how they were constructed. The second query produces: <?xml version="1.0" encoding="UTF-8"?> <last>Smith</last> <last>Jones</last> <last>Evans</last> <last>Hardy</last> This is also correct. This query has created a sorted sequence of four parentless element nodes, and then displays the contents of the four elements in document order. Because the four elements have no common root node, document order in this situation is implementation-defined. There is nothing in this construct that causes the sequence order to be retained. In practice, document order across disjoint trees in Saxon usually reflects the order in which the trees were created, but you shouldn't rely on this. Michael Kay

RE: XQuery: nested constructors - a bug? - Added by Anonymous over 19 years ago

Legacy ID: #3073906 Legacy Poster: p-h7 (p-h7)

Thanks for explanation. Pavel

    (1-2/2)

    Please register to reply