In answer to the many requests we've had for a way to move a node from
one document to another (that is change the ownerDocument attribute of a
node) I implemented a method called "adoptNode" on
org.apache.xerces.dom.DocumentImpl. I checked it in.

If people could give it a try and let me know if there is any problem.
To use it, cast your Document object into a DocumentImpl and then do
just like you would with importNode. There is no deep flag, though. It's
always deep. There isn't much sense in moving a node without its
children, what would happen to the children?

I haven't yet nailed down all the special cases such as moving a
Document node or so, but it should work fine for the typical use-cases.
One last thing, moving a node only works between two documents from the
same DOMImplementation, otherwise a NOT_SUPPORTED_ERR DOMException is
raised.

Enjoy!
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

Reply via email to