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

Re: eq operator

From: Tobias Reif <tobiasreif@pinkjuice.com>
Date: Wed, 21 May 2003 22:24:20 +0200
Message-ID: <3ECBE074.9080608@pinkjuice.com>
To: public-qt-comments@w3.org
CC: Jeni Tennison <jeni@jenitennison.com>

Hi Jeni

 > Note that eq and op:node-equal() are not at all related. eq is used
 > for comparing atomic values; if you try to compare two nodes using eq
 > then you will compare their atomised values. op:node-equal() is used
 > by the "is" and "isnot" operators, not the eq operator.

"A comparison with the is operator is true if the two operands are nodes 
that have the same identity;"

So "is" and "isnot" operators should use something named 

 > Could you give an example of a transformation where you think such a
 > function would be useful? I have great difficulty understanding what
 > your idea of fn:shallow-equal() is and, more importantly, why you
 > think it would be useful.

In a testing framework, I'm comparing pairs of forrests by comparing 
each pair of trees.
I'm doing this with fn:deep-equal(), which works well.
Now, instead of getting true or false back, I'd like to get the first 
different item (eg node) back instead of false.

I need a fn:deep-equal() which returns the first different node:
It would recurse down the tree (just as fn:deep-equal() does), stop as 
soon as it finds a different node in the second tree, and return it.

When being fed


   <blam att="val"/>

it would return
   <blam att="val"/>
or the pair as sequence:
   <blam att="val"/>

While recursing, the function would compare each node pair by calling 
s.th. like

Yes I could quite easily write the recursing function and the comparing 
shallow-equal() myself (eg: if node-kind($node) = 'text' then compare 
the string, otherwise etc etc), and I probably will, but I think it 
would be a useful addition to a standard lib (be it designed and 
specified by EXSLT or W3C).


Received on Wednesday, 21 May 2003 16:25:48 UTC

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