[Bug 2634] [XPath] Comparing QNames

http://www.w3.org/Bugs/Public/show_bug.cgi?id=2634

           Summary: [XPath] Comparing QNames
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XPath
        AssignedTo: chamberl@almaden.ibm.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


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: "Two variable references are equivalent if their local names are
the same..."

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

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

XPath 2.5.4.4: "the name of the candidate node is customer "

XPath 2.5.4.5: "attribute(AttributeName) matches any attribute node whose name
is AttributeName,"

It'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 "eq" operator on QNames
that does something different? What purpose does it serve? If we defined "eq" to
use codepoint comparison, then all the comparisons we perform in the language
could be specified to use the semantics of "eq"; and moreover, people doing
queries on stylesheets or schemas that make extensive use of QNames-in-content
would get the right answer. 

Michael Kay

Received on Tuesday, 3 January 2006 18:06:34 UTC