best approach to whole document cloning in Xerces2?

Jacob Kjome <[email protected]> Sun, 16 Apr 2006 01:17:10 -0500
Newsgroups gmane.text.xml.general
Message-ID <[email protected]>
I'm wondering what's the best approach to cloning an entire 
document?  Would it be better to keep a master copy in memory and 
then create a new document and import the other document in there, or 
would it be better to simply reparse the document every time (where 
the document is used over and over again as a template, a copy is 
created and manipulated on each HTTP request, then serialized to the 
browser)?  If I keep the document in memory and know I am dealing 
with the Xerces2 implementation, can I just call cloneNode(true) and 
get an identical copy of the whole document, including doctype, 
entities, entity references, etc...?  Again, would this be more 
efficient than reparsing the document each time with, say, the 
Xerces2 DOMParser?  Is there a clear-cut answer to this, or does it 
depend on document size or other aspect of the document or environment?

thanks,

Jake