You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Simon Tyler <ty...@hotmail.com> on 2001/02/01 17:41:02 UTC

Copying a Document

Hi,

I'm writing an application where I want to be to copy an entire DOM before 
modifying the original. The DOM in question has been generated using an XML 
Schema and had lots of defaulted attributes in it.

Initially I thought that the code:

Document newDoc = doc.cloneNode(true);

would work. However it fails to copy the defaulted attributes. I've had a 
look around and it seems that the importNode method is appropriate but so 
far I have failed to get it to work. Does someone have some code that can 
create a complete copy of a Document in Java (Using Xerces 1.2.3).

One way to do it would be to serialize the DOM to memory and the re-read it 
but this seems like a particularly nasty way to do it!

BTW Does anyone know where there is a update archivbe of this list. The one 
referenced from apache.org stops at the end of December 2000.

Simon
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.