<?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>6871</bug_id>
          
          <creation_ts>2009-05-08 12:28:00 +0000</creation_ts>
          <short_desc>[FO] Erronneous value comparison operator mapping for xs:time?</short_desc>
          <delta_ts>2012-03-29 08:02:11 +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>Functions and Operators 1.0</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</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>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Bogdan Butnaru">bogdanb+w3c+bugzilla</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>25025</commentid>
    <comment_count>0</comment_count>
    <who name="Bogdan Butnaru">bogdanb+w3c+bugzilla</who>
    <bug_when>2009-05-08 12:28:00 +0000</bug_when>
    <thetext>Hello,


Currently the spec at http://www.w3.org/TR/2007/REC-xpath-functions-20070123/ contains the following notes:

*** quote ***
10.4.12 op:time-equal [...] This function backs up the &quot;eq&quot;, &quot;ne&quot;, &quot;le&quot; and &quot;ge&quot; operators on xs:time values.

10.4.13 op:time-less-than [...] This function backs up the &quot;lt&quot; and &quot;le&quot; operators on xs:time values.

10.4.14 op:time-greater-than [...] This function backs up the &quot;gt&quot; and &quot;ge&quot; operators on xs:time values.
*** end quote ***

However, according to http://www.w3.org/TR/2007/REC-xquery-20070123/#mapping the operators are mapped thus:

A eq B -&gt; op:time-equal(A, B)
A ne B -&gt; fn:not(op:time-equal(A, B))
A gt B -&gt; op:time-greater-than(A, B)
A lt B -&gt; op:time-less-than(A, B)
A ge B -&gt; fn:not(op:time-less-than(A, B))
A le B -&gt; fn:not(op:time-greater-than(A, B))

The mapping would suggest that op:time-equal backs up &quot;eq&quot; and &quot;ne&quot;; op:time-greater-than backs up &quot;gt&quot; and &quot;le&quot;; and op:time-less-than backs up &quot;lt&quot; and &quot;ge&quot;.

However I&apos;m not sure the mapping in the XQuery spec is what is intended: Using that mapping, two xs:time values that should be incomparable because of time-zone differences would return false from the &quot;eq&quot;, &quot;gt&quot; and &quot;lt&quot; operators, but true for &quot;ne&quot; (correct), &quot;ge&quot; and &quot;le&quot;—the latter two would seem wrong. To reflect incomparable values, the &quot;le&quot; and &quot;ge&quot; operators should map to “op:time-less-than(A, B) or op:time-equal(A, B)” and “op:time-greater-than(A, B) or op:time-equal(A, B)”, respectively, similar to how numeric values are compared.

I think something similar should apply to xs:dateTime, but I haven&apos;t checked thoroughly that case yet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25134</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-05-13 12:00:19 +0000</bug_when>
    <thetext>&gt;The mapping would suggest that op:time-equal backs up &quot;eq&quot; and &quot;ne&quot;;
op:time-greater-than backs up &quot;gt&quot; and &quot;le&quot;; and op:time-less-than backs up
&quot;lt&quot; and &quot;ge&quot;.

Yes, I think that&apos;s correct, and the &quot;backs up&quot; statements should be corrected.

&gt;However I&apos;m not sure the mapping in the XQuery spec is what is intended: Using
that mapping, two xs:time values that should be incomparable

All xs:time values are comparable using these operators. Timezone differences are handled by applying the implicit timezone.

I&apos;m not absolutely sure whether the two possible definitions of the operators are equivalent, for example whether not($s lt $t) is always equivalent to ($s eq $t or $s gt $t), but to avoid depending on this we should be consistent in how it&apos;s defined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25179</commentid>
    <comment_count>2</comment_count>
    <who name="Bogdan Butnaru">bogdanb+w3c+bugzilla</who>
    <bug_when>2009-05-16 09:15:15 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; &gt;However I&apos;m not sure the mapping in the XQuery spec is what is intended: Using
&gt; that mapping, two xs:time values that should be incomparable
&gt; 
&gt; All xs:time values are comparable using these operators. Timezone differences
&gt; are handled by applying the implicit timezone.

You&apos;re right, I&apos;m sorry. This part of my report should be disregarded. I think I had mixed up the XQuery and XML Schema specs.
 
&gt; I&apos;m not absolutely sure whether the two possible definitions of the operators
&gt; are equivalent, for example whether not($s lt $t) is always equivalent to ($s
&gt; eq $t or $s gt $t), but to avoid depending on this we should be consistent in
&gt; how it&apos;s defined.

They are equivalent whenever the operators create a total order. IIRC, xs:times with and without timezones are not totally ordered in the sense of XML Schema, but they are totally ordered with respect to the XQuery gt/lt/eq operators. The implicit timezone bridges the two “ordering domains”. That&apos;s what confused my original report.

Should the original description be edited, or are these comments enough?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25890</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-07-07 15:32:52 +0000</bug_when>
    <thetext>Agreed that we will change the &quot;backs up&quot; sentences to match what&apos;s in the table. This is editorial so we are marking it FIXED.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66219</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-03-29 08:02:11 +0000</bug_when>
    <thetext>I discovered that this change had not been applied in the 3.0 specifications, and I have now applied it (affects the less-than and greater-than functions for date, time, and dateTime).

I have also added this to the list of candidate errata for the 1.0/2.0 specification.

I am now taking the opportunity to mark the bug closed, so it no longer comes up as needing attention.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>