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 29693 - [XP31] Order of result of SimpleMapExpr
Summary: [XP31] Order of result of SimpleMapExpr
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-11 14:34 UTC by Abel Braaksma
Modified: 2016-06-21 15:47 UTC (History)
1 user (show)

See Also:


Attachments

Description Abel Braaksma 2016-06-11 14:34:51 UTC
Under 3.15 Simple Map Operator (!) we say, among other things:

"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."

I'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 "orderings within subsequences". But I am not sure what the "ordering among subsequences" 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?
Comment 1 Abel Braaksma 2016-06-11 14:37:57 UTC
> In either case, may I suggest we either add an example, or a Note, that 
> explains this more clearly?
Actually, there is an example that seems to go against the text:

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

Here, "but retaining the order of documents" seems to be contrary to "the order of the returned sequence is implementation-dependent". I would expect, "but not necessarily retaining the order of documents" (or something along those lines).
Comment 2 Michael Kay 2016-06-11 17:55:38 UTC
(1) There'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 "otherwise" clause, but it has lost the "if" condition to which it relates. (XPath does not have an "ordering mode"). The "otherwise" clause should therefore be dropped.

(2) The "within and among" formulation is possibly a bit informal, but I can't immediately think of a good way of improving it.
Comment 3 Jonathan Robie 2016-06-21 15:47:30 UTC
Nice catch - I'll fix this.