<?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>28041</bug_id>
          
          <creation_ts>2015-02-17 15:48:56 +0000</creation_ts>
          <short_desc>[XSLT30] Maps have implementation defined order, but this is not specified as such</short_desc>
          <delta_ts>2015-10-29 09:50:44 +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>XSLT 3.0</component>
          <version>Member-only Editors Drafts</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="Abel Braaksma">abel.online</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>abel.braaksma</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>117988</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2015-02-17 15:48:56 +0000</bug_when>
    <thetext>Under map:keys we say that the order of the result is implementation defined. Under maps (section 21.1 and 21.1.1) we do not say such a thing.

Furthermore, we do not clarify whether deep-equal(map:keys($m), map:keys($m)) is pairwise equal or not, but we do say that map:keys is deterministic (and the definition of deterministic in XP30 is defined that it must be pairwise equal).

The function map:for-each-entry has the same ambiguity.

This bug equally applies to XSLT 3.0 LCWD and XPFO 3.1 CR.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118163</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-02-25 21:23:23 +0000</bug_when>
    <thetext>It&apos;s not correct to suggest that 21.1 says nothing. It defines a map as &quot;A map consists of a set of entries. &quot; Defining it as a set makes it clear that in the data model, there is no intrinsic order. The problem only arises with functions that have to presen the set as a sequence, namely map:keys() and map:for-each-entry().

It&apos;s also clear for both these functions that the result order is implementation-dependent (NB, not implementation-defined).

So the only remaining question is whether, when the results of a function are implementation-dependent but deterministic, two calls with the same arguments are required to deliver the same result. F+O answers this question in 1.6.4:

&lt;quote&gt;
Some functions (such as fn:distinct-values and fn:unordered) produce results in an ·implementation-defined· or ·implementation-dependent· order. In such cases there is no guarantee that the order of results from different calls will be the same. These functions are said to be non-deterministic with respect to ordering.
&lt;/quote&gt;

That seems clear enough to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118180</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-02-26 12:14:06 +0000</bug_when>
    <thetext>It wasn&apos;t immediately obvious to me that the term set had that meaning, but it makes sense now. 

The section in F&amp;O you refer to starts with 

&quot;All functions defined in this specification are ·deterministic· unless otherwise stated. Exceptions include the following:&quot;. 

But if we look up the said functions (fn:unordered), it is deemed deterministic and there is no notion that it is non-deterministic in regards to ordering. I am unsure whether this is a closed set of functions or not and whether it applies to extension functions like the ones we define in XSLT.

Does it perhaps make sense to add a line something like &quot;this function is non-deterministic with respect to ordering&quot; and/or refer to that section in F&amp;O?.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118703</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-03-20 10:00:25 +0000</bug_when>
    <thetext>The WG resolved to fix this by adding, in the specifications of map:keys and map:for-each, a reference to the definition of functions that are &quot;non-deterministic with respect to order&quot; in F+O. This reference has been added to both the XSLT 3.0 and XPath 3.1 versions of the specifications.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>