<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>9276</bug_id>
          
          <creation_ts>2010-03-18 16:48:22 +0000</creation_ts>
          <short_desc>[XQTS] Order of results of fn-doc-33 are not well defined.</short_desc>
          <delta_ts>2010-06-07 12:43:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Query Test Suite</product>
          <component>XML Query Test Suite</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Oliver Hallam">oliver</reporter>
          <assigned_to name="Martin Probst">Probst_Martin</assigned_to>
          <cc>jim.melton</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>33691</commentid>
    <comment_count>0</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2010-03-18 16:48:22 +0000</bug_when>
    <thetext>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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35997</commentid>
    <comment_count>1</comment_count>
    <who name="Martin Probst">Probst_Martin</who>
    <bug_when>2010-06-06 11:42:23 +0000</bug_when>
    <thetext>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=&quot;none&quot; stroke=&quot;blue&quot; stroke-width=&quot;2&quot;/&gt;,
      &lt;s:rect x=&quot;400&quot; y=&quot;100&quot; width=&quot;400&quot; height=&quot;200&quot;
         fill=&quot;yellow&quot; stroke=&quot;navy&quot; stroke-width=&quot;10&quot;  /&gt;,
-        for $i in $root//QObject/local:drawDiagram(.)
+        for $object in $root//QObject
+        for $i local:drawDiagram($object)
         stable order by string($i)
         return $i
     }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36019</commentid>
    <comment_count>2</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2010-06-07 12:00:48 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36021</commentid>
    <comment_count>3</comment_count>
    <who name="Martin Probst">Probst_Martin</who>
    <bug_when>2010-06-07 12:43:42 +0000</bug_when>
    <thetext>Closing.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>