You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Matthias Brunner <mb...@blumenstrasse.vol.at> on 2002/12/05 14:46:58 UTC

isChildOf function?

Hello,

how can I find out whether a node is a child of another node?

"child.getParentNode() == parent" and 
"child.getParentNode().equals(parent)" do not seem to work.

Best regards!
-- 
Matthias Brunner <mb...@blumenstrasse.vol.at>
PGP FP 7862 32B3 3B75 292A F76F  5042 8587 21AB 5B89 D501
Check out http://blumenstrasse.vol.at/~mb/gpgkey.asc


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: isChildOf function?

Posted by Matthias Brunner <mb...@blumenstrasse.vol.at>.
On Thursday 05 December 2002 15:14, Joseph Kesselman wrote:
> (As an alumnus of the DOM Working Group, I believe the official
> statement which covers this situation is "oops".)
>
I suspected it the very moment I wrote this mail :)
Thanks for your helpful reply!
-- 
Matthias Brunner <mb...@blumenstrasse.vol.at>
PGP FP 7862 32B3 3B75 292A F76F  5042 8587 21AB 5B89 D501
Check out http://blumenstrasse.vol.at/~mb/gpgkey.asc


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: isChildOf function?

Posted by Joseph Kesselman <ke...@us.ibm.com>.
>how can I find out whether a node is a child of another node?
>"child.getParentNode() == parent" and 
>"child.getParentNode().equals(parent)" do not seem to work.

The latter shouldn't work; equals() is not defined for DOM nodes. (Do you 
mean "same node" or "equal content"?)

The former should work in Xerces... but is not portable; the DOM does not 
guarantee that object identity and node identity are the same thing.

The portable answer will be the DOM Level 3 isSameNode() method. 
Unfortunately, since Level 3 is not yet an official Recommendation, and 
since not all DOMs will implement Level 3, this is also not fully 
portable... but it's the best we're going to get.

Best recommendation I can offer you is to write a wrapper routine that 
checks which DOM implementation you're working with and uses isSameNode() 
if available and some fallback (probably ==) if not. Or accept that your 
code's going to be a bit nonportable, or is going to be locked into DOM3 
and later.


(As an alumnus of the DOM Working Group, I believe the official statement 
which covers this situation is "oops".)

______________________________________
Joe Kesselman  / IBM Research

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org