<?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>1208</bug_id>
          
          <creation_ts>2005-04-05 09:09:51 +0000</creation_ts>
          <short_desc>[F&amp;O] deep-equal() is not transitive and reflexive</short_desc>
          <delta_ts>2005-09-29 10:39:12 +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>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</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>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Ashok Malhotra">ashok.malhotra</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>3800</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-04-05 09:09:51 +0000</bug_when>
    <thetext>The deep-equal() function as currently defined is not transitive and it is not
reflexive (it does not guaranteed that deep-equal($A, $A) is true).

The known problems are as follows:

A. The transitivity problem arises from the condition that two elements are
deep-equal if (among other things):

# One of the following conditions holds:

    * Both element nodes have a type annotation that is either a simple type or
a complex type with simple content, and the typed value of $i1 is deep-equal to
the typed value of $i2.
    * One or both of the element nodes has a type annotation that is neither a
simple type nor a complex type with simple content, and the sequence
$i1/(*|text()) is deep-equal to the sequence $i2/(*|text()).

This means that given

X: &lt;a&gt;1&lt;/a&gt; of type xs:integer
Y: &lt;a&gt;1.0&lt;/a&gt; of type xs:decimal
Z: &lt;a&gt;1&lt;/a&gt; of type xs:anyType

we have X=Y, X=Z, and Y!=Z.

B. The function is not reflexive because of the possibility of NaN values. If $X
is a document that contains a typed NaN value at any depth, then deep-equal($X,
$X) is false.

C. The lack of support for comparison of durations also leads to a problem. If
$X is a document that contains a typed xs:duration value at any depth, then
deep-equal($X, $X) is false.

The effect of these problems is that deep-equal is difficult for an optimizer to
handle, for example if it is used as a join condition then it&apos;s not possible to
support it using a hash join. It also means that the function is not suitable to
underpin future developments that introduce a grouping capability or a
deep-distinct() function.

There are several things we could do about the problem:

Option 1: scrap the function

Option 2: live with its deficiencies

Option 3: fix the problems

3A. Specify that two elements can be deep-equal only if they are both annotated
as having complex content or both annotated as having simple content.

3B. Specify that for the purposes of deep-equal, NaN is equal to NaN. (We
already have this rule for distinct-values())

3C. Specify an equality comparison for xs:duration values. Unlike ordering,
there is no good reason for this to be unsupported. Any duration can be simply
and unambiguously represented as the sum of a dayTimeDuration and a
yearMonthDuration and we simply specify that two durations are equal if these
two components are equal.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3091</commentid>
    <comment_count>1</comment_count>
    <who name="Ashok Malhotra">ashok.malhotra</who>
    <bug_when>2005-05-26 20:54:40 +0000</bug_when>
    <thetext>The joint WGs decided on 5/17/2005 to close this bug by accepting Michael Kay&apos;s
recommendations.  Ashok Malhotra requested clarification on 3A which were
provided by Michael Kay and Henry Thompson in (member-only) messages:
http://lists.w3.org/Archives/Member/w3c-xsl-query/2005May/0079.html and
http://lists.w3.org/Archives/Member/w3c-xsl-query/2005May/0080.html</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>