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 28041 - [XSLT30] Maps have implementation defined order, but this is not specified as such
Summary: [XSLT30] Maps have implementation defined order, but this is not specified as...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Member-only Editors Drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-17 15:48 UTC by Abel Braaksma
Modified: 2015-10-29 09:50 UTC (History)
1 user (show)

See Also:


Attachments

Description Abel Braaksma 2015-02-17 15:48:56 UTC
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.
Comment 1 Michael Kay 2015-02-25 21:23:23 UTC
It's not correct to suggest that 21.1 says nothing. It defines a map as "A map consists of a set of entries. " 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'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:

<quote>
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.
</quote>

That seems clear enough to me.
Comment 2 Abel Braaksma 2015-02-26 12:14:06 UTC
It wasn't immediately obvious to me that the term set had that meaning, but it makes sense now. 

The section in F&O you refer to starts with 

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

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 "this function is non-deterministic with respect to ordering" and/or refer to that section in F&O?.
Comment 3 Michael Kay 2015-03-20 10:00:25 UTC
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 "non-deterministic with respect to order" in F+O. This reference has been added to both the XSLT 3.0 and XPath 3.1 versions of the specifications.