<?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>29693</bug_id>
          
          <creation_ts>2016-06-11 14:34:51 +0000</creation_ts>
          <short_desc>[XP31] Order of result of SimpleMapExpr</short_desc>
          <delta_ts>2016-06-21 15:47:30 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XPath 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</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="Abel Braaksma">abel.braaksma</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>mike</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>126733</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-06-11 14:34:51 +0000</bug_when>
    <thetext>Under 3.15 Simple Map Operator (!) we say, among other things:

&quot;These sequences are concatenated and returned. The returned sequence preserves the orderings within and among the subsequences generated by the evaluations of E2; otherwise the order of the returned sequence is implementation-dependent.&quot;

I&apos;m not sure I fully understand this sentence. It seems to me that it says that:

(1, 2) ! .

can return (1, 2) or (2, 1), depending of order of evaluation. This would fit the &quot;orderings within subsequences&quot;. But I am not sure what the &quot;ordering among subsequences&quot; means. For instance:

(1, 2) ! ((3, 4), ., (5, 6))

Here I see three subsequences, (3,4), (.), and (5,6). Are that the subsequences this text refers to and their order with respect to one another should be maintained? I.e., are the following two outcomes both legal?

 (3, 4, 1, 5, 6, 3, 4, 2, 5, 6)
 (3, 4, 2, 5, 6, 3, 4, 1, 5, 6)

If so, I am surprised about this rule, as I would expect the bang-operator to return the items in sequence order. Evaluation order is undefined, of course, but returned sequence should (I think) be in the order of the input sequence (the left-hand operand).

In either case, may I suggest we either add an example, or a Note, that explains this more clearly?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126734</commentid>
    <comment_count>1</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-06-11 14:37:57 +0000</bug_when>
    <thetext>&gt; In either case, may I suggest we either add an example, or a Note, that 
&gt; explains this more clearly?
Actually, there is an example that seems to go against the text:

&lt;quote&gt;
$docs ! ( //employee)

Returns all the employees within all the documents identified by the variable docs, in document order within each document, but retaining the order of documents.
&lt;/quote&gt;

Here, &quot;but retaining the order of documents&quot; seems to be contrary to &quot;the order of the returned sequence is implementation-dependent&quot;. I would expect, &quot;but not necessarily retaining the order of documents&quot; (or something along those lines).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126736</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-06-11 17:55:38 +0000</bug_when>
    <thetext>(1) There&apos;s a problem here in the XPath version.

XQuery has:
If ordering mode is ordered, the returned sequence preserves the orderings within and among the subsequences generated by the evaluations of E2; otherwise the order of the returned sequence is implementation-dependent.

while XPath has:
The returned sequence preserves the orderings within and among the subsequences generated by the evaluations of E2; otherwise the order of the returned sequence is implementation-dependent.

The XPath version retains the &quot;otherwise&quot; clause, but it has lost the &quot;if&quot; condition to which it relates. (XPath does not have an &quot;ordering mode&quot;). The &quot;otherwise&quot; clause should therefore be dropped.

(2) The &quot;within and among&quot; formulation is possibly a bit informal, but I can&apos;t immediately think of a good way of improving it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126812</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2016-06-21 15:47:30 +0000</bug_when>
    <thetext>Nice catch - I&apos;ll fix this.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>