- From: David Brownell <david-b@pacbell.net>
- Date: Tue, 14 Mar 2000 12:42:42 -0800
- To: Eric Richardson <maxwell@telesoft.com>, DOM <www-dom@w3.org>
> I have a template in one XML doc. I want to retrieve an Element from > that template and insert it into the another Document I am working on in > the DOM. Since you're using Sun's DOM, you should be able to use the DocumentEx.changeNodeOwner (Node) method efficiently get past the DOM "can't move nodes between Documents" restriction. I like that better than the DOM L2 approach of Document.importNode (Node) because (a) it's memory-efficient in the typical single-implementation case, (b) successful results can't discard subclass-specific per-instance data, (c) importNode is really just a convenience method, but changeNodeOwner exposes a capability that couldn't otherwise be accessed. If you didn't want to mutate the original (template) document then you will need some sort of clone operation, like L2 importNode. I've seen operations speed up substantially (factors of at least two) when those cloning operations were removed. - Dave
Received on Tuesday, 14 March 2000 15:43:23 UTC