The Artima Developer Community
Sponsored Link

Java Answers Forum
to DOM...

1 reply on 1 page. Most recent reply: Mar 23, 2005 5:20 AM by Amol Brid

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
park jung gyu

Posts: 4
Nickname: dalantpark
Registered: Mar, 2005

to DOM... Posted: Mar 23, 2005 4:57 AM
Reply to this message Reply
Advertisement
Why parent1 and parent2 must add same Element in sequence when parent1 remove it after inserting to parent1?

ex)
Document doc = new org.apache.xerces.dom.DocumentImpl();

Element ele = doc.createElement("element");

parent1.appendNode(ele);
parent2.appendNode(ele);

next, it removes ele from parent1.

why mustn't write...

parent1.appendNode(ele);

next, it removes ele from parent1.

parent2.appendNode(ele);


after removing above, Is ele object disposed.


Amol Brid

Posts: 43
Nickname: amolbrid
Registered: Feb, 2004

Re: to DOM... Posted: Mar 23, 2005 5:20 AM
Reply to this message Reply
Hi,
I have not fully understood your question. But if you mean that why ele is removed from parent1 and is ele valid for GC the read this:

you cannot add a element as a child of two different parents. If you try to do this then the child element is removed from the first parent.

In your case the element refered by ele will be removed from parent1 and added to parent2, but the element refered by ele will not be garbage collected since parent2 refers to it.

Revert back if you don't understand it.

Regards,
Amol Brid.

Flat View: This topic has 1 reply on 1 page
Topic: apcs kid in need of helpxor Previous Topic   Next Topic Topic: Need clarification on GC process

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use