W3C home > Mailing lists > Public > public-qt-comments@w3.org > May 2009

[Bug 6861] [XPath] general comparison operator '='

From: <bugzilla@wiggum.w3.org>
Date: Sat, 02 May 2009 16:05:59 +0000
To: public-qt-comments@w3.org
Message-Id: <E1M0Hix-0004Ew-3J@wiggum.w3.org>

Michael Kay <mike@saxonica.com> changed:

           What    |Removed                     |Added
                 CC|                            |mike@saxonica.com

--- Comment #2 from Michael Kay <mike@saxonica.com>  2009-05-02 16:05:58 ---
>Why does the XPath 2.0 spec defines the semantics of operator '=' in such a way that, magnitude equality of only 1 item is enough, for '=' operator to return 'true'?

Well, XPath 2.0 defines it this way because XPath 1.0 defined it that way, so
your question translates into, why did XPath 1.0 do it this way.

The factual answer is that I don't know: I wasn't at the meetings and haven't
studied the minutes. However, I can speculate.

With a predicate like book[title='Black Beauty'] it is very common that there
is only one title, and it should be easy and intuitive to write such a query
for books with only one title. If a book has no title, it seems intuitive that
the predicate should not select the book. This only leaves the question of what
should be done if there are multiple titles. In some other situations, XPath
1.0 took the approach of selecting the first title. Another approach, favoured
in some situations in XPath 2.0, is to raise an error. Dynamic errors were not
part of the culture of XPath 1.0 (and given all the problems we have since had
with errors and optimizations, I have increasing sympathy with this design
choice.) Choosing to compare the first item only would have probably been more
consistent, but it's not clear that it would have been a more intuitive

Anyway, this decision was made more than ten years ago, and it seems to work
reasonably well. If someone were starting from scratch, I expect they would do
it differently, but it's not clear to me that they would do it better - XPath
has proved remarkably successful.

Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Saturday, 2 May 2009 16:06:11 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:39 UTC