- From: <nobody@w3.org>
- Date: Fri, 07 Aug 2015 14:13:07 +0000
- To: public-qt-comments@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29044
Bug ID: 29044
Summary: array:sort does not define a total order when keys
contain NaN
Product: XPath / XQuery / XSLT
Version: Candidate Recommendation
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: Functions and Operators 3.1
Assignee: mike@saxonica.com
Reporter: josh.spiegel@oracle.com
QA Contact: public-qt-comments@w3.org
Target Milestone: ---
Group: XSLXQuery_WG
Consider this query:
let $a := (xs:float("NaN"), 1)
let $b := (xs:float("NaN"), 2)
return array:sort([$a, $b])
The result of this query is not well defined.
<quote>
The order of members in the result is such that, given two members $A and $B:
if (fn:deep-equal($key($A), $key($B)), then the relative order of $A and $B
in the output is the same as their relative order in the input (that is,
the sort is stable)
if (deep-less-than($key($A), $key($B)), then $A precedes $B in the output.
The function deep-less-than is defined as the boolean result of the
expression:
if (empty($A)) then exists($B)
else if ($A[1] eq $B[1]) then deep-less-than(fn:tail($A), fn:tail($B))
else $A[1] lt $B[1]
</quote>
* fn:deep-equals(data($a), data($b)) is false
* deep-less-than(data($a), data($b)) is false
* deep-less-than(data($b), data($a)) is false
Using deep-equal instead of eq may fix the problem:
if (empty($A)) then exists($B)
else if (deep-equal($A[1],$B[1]) then deep-less-than(fn:tail($A),
fn:tail($B))
else $A[1] lt $B[1]
The expected result of above query would then be:
[(xs:float("NaN"), 1), (xs:float("NaN"), 2)]
--
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Friday, 7 August 2015 14:13:10 UTC