This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 9276 - [XQTS] Order of results of fn-doc-33 are not well defined.
Summary: [XQTS] Order of results of fn-doc-33 are not well defined.
Status: CLOSED FIXED
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Martin Probst
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-18 16:48 UTC by Oliver Hallam
Modified: 2010-06-07 12:43 UTC (History)
1 user (show)

See Also:


Attachments

Description Oliver Hallam 2010-03-18 16:48:22 UTC
One section of this query is as follows:

for $i in $root//QObject/local:drawDiagram(.)
stable order by string($i)
return $i

The fact that the order by is stable does no good here!

The problem lies with the path expression $root//QObject/local:drawDiagram(.)

Following the rules in [XQuery] 3.2, the nodes returned from the path expression are sorted into document order and deduplicated.

However, all the nodes in this sequence are newly constructed, and thus have an implementation defined order.

Whilst it is undesirable for an implementation to return the nodes in an arbitrary permutation, it is allowed by the spec.  I cannot see how the spec could be easily changed to allow for this seemingly useful use-case, so I have marked this as a bug against XQTS.

The simplest solution I can see is to replace the for expression with a for expression:

for $object in $root//QObject 
for $i in local:drawDiagram($object)
stable order by string($i)
return $i
Comment 1 Martin Probst 2010-06-06 11:42:23 UTC
I agree with the analysis and the resolution. Also of potential interest is that the test creates a result SVG document that is not well-formed according to xml:id rules; it contains duplicate IDs.

The solution appears to be already implemented in latest XQTS CVS state (both .xq and .xqx), except for the (almost) identical static test fn-doc-33-static-cbcl.xq. This patch fixes it, but the .xqx file will need to be re-generated:


Index: ./Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-33-static-cbcl.xq
===================================================================
RCS file: /sources/public/2006/xquery-test-suite/TestSuiteStagingArea/Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-33-static-cbcl.xq,v
retrieving revision 1.1
diff -u -r1.1 fn-doc-33-static-cbcl.xq
--- ./Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-33-static-cbcl.xq	13 Mar 2008 12:14:17 -0000	1.1
+++ ./Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-33-static-cbcl.xq	6 Jun 2010 11:41:06 -0000
@@ -38,7 +38,8 @@
         fill="none" stroke="blue" stroke-width="2"/>,
      <s:rect x="400" y="100" width="400" height="200"
         fill="yellow" stroke="navy" stroke-width="10"  />,
-        for $i in $root//QObject/local:drawDiagram(.)
+        for $object in $root//QObject
+        for $i local:drawDiagram($object)
         stable order by string($i)
         return $i
     }
Comment 2 Oliver Hallam 2010-06-07 12:00:48 UTC
I have made the change you propose, and am marking this bug FIXED.  Since I was the person that originally posted the bug it is probably wise to let you close it.
Comment 3 Martin Probst 2010-06-07 12:43:42 UTC
Closing.