W3C home > Mailing lists > Public > public-qt-comments@w3.org > April 2003

node-equal(), node-identical()

From: Tobias Reif <tobiasreif@pinkjuice.com>
Date: Tue, 15 Apr 2003 13:34:27 +0200
Message-ID: <3E9BEE43.4040908@pinkjuice.com>
To: public-qt-comments@w3.org

Hi

If I want to compare two trees for equality (comparing actual test 
output to the desired test output), I can use deep-equal()
http://www.w3.org/TR/xquery-operators/#func-deep-equal .

Now if the two trees are not equal, I need to find out where the first 
difference occurs (for example if the fourth element in the actual 
output is p, not span (... as specified in the desired output)).
I'd like to recurse through all the nodes (be it as list or as tree), 
compare them for equality, then stop as soon as a pair is not equal. 
Then I can output something like "test 5 failed: the fourth element is 
p, not span".

It's probably obvious, but how can I test two nodes for equality?
I'm sure there exists a very simple solution, but the current draft is 
inconsistent and confusing in this regard, IMHO:

http://www.w3.org/TR/xquery-operators/#func-node-equal
"If the node identified by the value of $parameter1 is the same node as 
the node identified by the value of $parameter2 (that is, the two nodes 
have the same identity), then the function returns true; otherwise, the 
function returns false."

Shouldn't the function named "node-equal" compare two (possibly 
different) nodes for equality, not for identity?
(that's what I would use)

Shouldn't the function which tests for identity be named "node-identical"?

I'm not sure if a clarification or a change is required.

TIA,
Tobi

-- 
http://www.pinkjuice.com/
Received on Tuesday, 15 April 2003 07:35:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:24 GMT