- From: Tobias Reif <tobiasreif@pinkjuice.com>
- Date: Wed, 21 May 2003 22:24:20 +0200
- 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. http://www.w3.org/TR/xpath20/#id-node-comparisons "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 op:node-identical(). > 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 <foo> <bar/> <blam/> </foo> <foo> <bar/> <blam att="val"/> </foo> it would return <blam att="val"/> or the pair as sequence: <blam/> <blam att="val"/> . While recursing, the function would compare each node pair by calling s.th. like shallow-equal($current_node_in_tree_1,$current_node_in_tree_2) 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). Tobi -- http://www.pinkjuice.com/
Received on Wednesday, 21 May 2003 16:25:48 UTC