<?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>2634</bug_id>
          
          <creation_ts>2006-01-03 18:06:23 +0000</creation_ts>
          <short_desc>[XPath] Comparing QNames</short_desc>
          <delta_ts>2006-02-15 21:50:51 +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>XPath 2.0</component>
          <version>Candidate Recommendation</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="Don Chamberlin">chamberl</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>7586</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-03 18:06:23 +0000</bug_when>
    <thetext>There are many places in the language where we compare QNames. We have two
different ways of comparing QNames: by codepoint-comparison, and using the
default collation. We either need to converge on a single way of comparing
QNames, or we need to be very explicit which method is used on every occasion
that the need for comparison arises.

Where a QName is used as a NameTest in a path expression, we are explicit that
codepoint comparison is used.

Where the eq operator is used to compare two values of type xs:QName, we are
explicit that the default collation is used.

In many other cases we are imprecise. Here are some examples from XPath; there
are many more examples of similarly fuzzy language in XSLT and XQuery:

XPath 3.1.2: &quot;Two variable references are equivalent if their local names are
the same...&quot;

XPath 3.1.5: &quot;If the expanded QName and number of arguments in a function call
do not match the name and arity of a function signature...&quot;

XPath 2.5.4: &quot;As usual, two expanded QNames are equal if their local parts are
the same and their namespace URI&apos;s are the same. &quot; (!)

XPath 2.5.4.4: &quot;the name of the candidate node is customer &quot;

XPath 2.5.4.5: &quot;attribute(AttributeName) matches any attribute node whose name
is AttributeName,&quot;

It&apos;s my belief that in all the above cases, the intent is actually to use
codepoint comparison on both the URI and the local-name.

So the real question that arises is, why do we have an &quot;eq&quot; operator on QNames
that does something different? What purpose does it serve? If we defined &quot;eq&quot; to
use codepoint comparison, then all the comparisons we perform in the language
could be specified to use the semantics of &quot;eq&quot;; and moreover, people doing
queries on stylesheets or schemas that make extensive use of QNames-in-content
would get the right answer. 

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7588</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2006-01-03 19:11:21 +0000</bug_when>
    <thetext>For all the path comparisons and node name tests it certainly should be 
codepoint based (otherwise we will get a completely different, harder to 
understand language).

For xs:QName, I would prefer also that we do not fall back to the default 
collation but do code point. Where does it say that we use default collation?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7590</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-03 20:17:39 +0000</bug_when>
    <thetext>&gt;Where does it say that we use default collation?

http://www.w3.org/TR/xpath-functions/#func-QName-equal

It surprised me!

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7591</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2006-01-03 20:20:23 +0000</bug_when>
    <thetext>It actually says:

Summary: Returns true if the namespace URIs of $arg1 and $arg2 are equal and 
the local names of $arg1 and $arg2 are identical based on the default 
collation. Otherwise, returns false. Two namespace URIs are considered equal 
if they are either both absent or both present and identical based on the 
Unicode code point collation (http://www.w3.org/2005/xpath-
functions/collation/codepoint). The prefix parts of $arg1 and $arg2, if any, 
are ignored.

Which mixes UCC and default collation.... 

IMO, it should just be UCC...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7592</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-03 21:03:07 +0000</bug_when>
    <thetext>Delving a bit further, this has changed since the October 2004 draft

http://www.w3.org/TR/2004/WD-xpath-functions-20041029/#func-QName-equal

In the minutes from Brisbane (Jan 2005)
http://lists.w3.org/Archives/Member/w3c-xml-query-wg/2005Jan/0112
we see:

RESOLUTION: &quot;[IR] IBM-FO-112: comparisons of URIs&quot; is closed.
op:QName-equal will be based on codepoint comparison. This was done in
the previous version of the document and needs to be rolled back.

This comment is at
http://lists.w3.org/Archives/Member/w3c-xsl-query/2004Dec/0013.html It proposes
changing the URI comparison to use the default collation, but says nothing about
the local name comparison. 

It seems to me entirely possible that the change happened as a result of some
confusion over the URI/string comparison issue (witness the decision first to
accept IBM-FO-112 and then to roll it back), and that there was no conscious
decision after October 2004 to change the comparison semantics for the local
part of the QName. Certainly I recall no such discussion.

Unfortunately, unlike many of our documents, the Feb 2005 working draft of F+O
does not include a change log.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8273</commentid>
    <comment_count>5</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2006-02-15 21:50:38 +0000</bug_when>
    <thetext>Mike,
The Query and XSLT working groups considered your comment at their joint 
meeting on 01 Feb 2006, and decided that all comparisons of QNames should be 
performed using code-point comparisons on both the local name and the namespace 
URI. The description of op:QName-equal in Functions and Operators will be 
edited accordingly, and clarifying text will be added to the XPath and XQuery 
specifications as needed. Thanks for calling this issue to the attention of the 
working groups. Since you were present during the discussion, I will mark this 
issue as Closed.
--Don Chamberlin (for the joint working groups)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>