<?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>30386</bug_id>
          
          <creation_ts>2018-12-27 02:14:41 +0000</creation_ts>
          <short_desc>[XSLT30] xsl:sort with collation and data-type=&quot;number&quot; should throw an error, but this is not made explicit</short_desc>
          <delta_ts>2019-03-08 15:55:43 +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>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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>
          
          
          <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>129466</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2018-12-27 02:14:41 +0000</bug_when>
    <thetext>Section 13.1.3 Sorting Using Collations describes the use of collations with sorting and explicitly states that the input must be xs:string/xs:anyURI or derived thereof.

Since the previous section describes that xs:untypedAtomic is converted to xs:string and empty-sequence is ordered before anything else, this seems fine.

But the input is converted to xs:float when data-type=&quot;number&quot;. This combination gives a sort keys that:

1) exists of items that are xs:float
2) must use collation on xs:string

I&apos;d be inclined to consider this an error scenario as written, though it can also be an oversight (i.e., should collation be ignored in that case?).

There&apos;s a test that currently expects this to work: sort-012, but my processor thrown an error XTDE1030, which has the surprising message that xs:float cannot be compared to itself.

I&apos;m leaning towards making this indeed an error, it seems illogical to have both collation and data-type=&quot;number&quot;. Though at the same time, there&apos;s something to say for ignoring the data-type attribute completely, but this isn&apos;t in the spec.

I have split the test in a version without collation (though as not to raise an error) and with collation (to throw the error). I&apos;d be interested in any thoughts on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129467</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2018-12-27 10:18:00 +0000</bug_when>
    <thetext>My instinct is that the collation, case-order, and lang attributes should be ignored when comparing values other than strings (or untyped atomic).

Firstly, I think all three attributes should be treated the same way.

Secondly, if it&apos;s going to be a static error when it can be detected statically then I think it should be a dynamic error when it can&apos;t: it&apos;s effectively a type error. But that leads to complications, e.g. what if the sequence is a singleton xs:date and a collation is specified? Do we have to detect that and raise an error?

Thirdly, I think the spec, by omission, says that this is not an error. If you follow the rules in the spec as written then you will not raise an error, and that means that it isn&apos;t. (It&apos;s probably a good case for a warning).

Fourthly, XSLT 1.0 explicitly says that lang is ignored if data-type=number, which creates a backwards compatibility issue.

You say that &quot;§13.1.3 explicitly states that the input must be xs:string/xs:anyURI or derived thereof.&quot; I don&apos;t think that&apos;s the case: there is no MUST here, no condition that must be satisfied, which would implicitly define an error if it isn&apos;t. Rather the section says &quot;The rules given in this section apply when comparing values whose type is xs:string or a type derived by restriction from xs:string, or whose type is xs:anyURI or a type derived by restriction from xs:anyURI.&quot; which to my mind says that the whole section is simply ignored when comparing non-string values.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129481</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-01-16 18:01:40 +0000</bug_when>
    <thetext>The removal of the collation attribute from test sort-012 makes the results implementation-defined, because the spec says:

If none of the collation, lang, or case-order attributes is present, the collation is chosen in an implementation-defined way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129494</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2019-02-13 14:32:40 +0000</bug_when>
    <thetext>Drafted erratum E45 to say that collation, case-order, and lang are ignored when there are no string-valued sort keys, including the case where data-type=&quot;number&quot;. If the attributes are ignored, then implementations may or may not report any errors in their values.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129517</commentid>
    <comment_count>4</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-19 19:42:50 +0000</bug_when>
    <thetext>(In reply to Michael Kay from comment #3)
&gt; Drafted erratum E45 to say that collation, case-order, and lang are ignored
&gt; when there are no string-valued sort keys, including the case where
&gt; data-type=&quot;number&quot;. If the attributes are ignored, then implementations may
&gt; or may not report any errors in their values.

Agreed, thanks.

I noticed a possible typo: &quot;implementation may report errors in the value of these attributes&quot;

s/in/on/  (at least, I think)
s/value/values/


For reference, deep-link: https://htmlpreview.github.io/?https://github.com/w3c/qtspecs/blob/master/errata/xslt-30/html/xslt-30-errata.html#E45</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129543</commentid>
    <comment_count>5</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-02-20 10:57:56 +0000</bug_when>
    <thetext>Giving this some more thought, I see now the problem with any other than the current solution. The test sort-012 dynamically switches between data-type=&quot;text&quot; and data-type=&quot;number&quot;. Code would become a lot harder to write if data-type number could not be combined with collations.

Saying that collations etc are ignored in such cases fixes this.

I&apos;m wondering if we could improve one more line in this section. The opening says:

&quot;The rules given in this section apply when comparing values whose type is xs:string or a type derived by restriction from xs:string, or whose type is xs:anyURI or a type derived by restriction from xs:anyURI. &quot;

It is highly implicit and not immediately clear that xs:untypedAtomic applies as well. Could we add this, for instance by referring to the atomization/conversion process in 13.1.2:

&quot;The rules given in this section apply when comparing values whose type is xs:string or a type derived by restriction from xs:string, or whose type is xs:anyURI or a type derived by restriction from xs:anyURI, after conversion as explained in 13.1.2 Comparing Sort Key Values.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129625</commentid>
    <comment_count>6</comment_count>
    <who name="Abel Braaksma">abel.online</who>
    <bug_when>2019-03-08 15:55:43 +0000</bug_when>
    <thetext>For posterity: Michael Kay removed test sort-012err in rev #2046, which was there initially as a case for testing the here discussed error scenario, which proved to be no error scenario.

Leaving this open for discussion of the erratum.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>