[jdom-interest] Question from a newbie - How to make a copy of a Document

Brad Morgan Brad.Morgan at e-pubcorp.com
Thu Aug 31 09:15:58 PDT 2000


I have a Java program that massages the XML index for a JavaHelp helpset to
produce an XML glossary.  Currently this program processes the files as
ASCII text.  I'd like to convert the program to process the documents as XML
using JDOM.

Both documents use the same DTD.  I have a list (produced by the authoring
tool) which I have parsed that provides me with a type for each indexitem
element.  When this type is glossary, I want to remove the indexitem from
the index XML file and add it to the glossary XML file.
The rest of the XML document should be identical.

One approach would be to use:

            SAXBuilder builder = new SAXBuilder();
		SAXBuilder builder2 = new SAXBuilder();
            // Create the document
            Document doc = builder.build(new File(filename));
	      Document doc2 = builder2.build(new File(filename));

and then walk both lists removing indexitems when type == glossary or type
!= glossary as appropriate, but in looking at the Javadoc documentation, I
see a clone() method with the comment "This will return a deep clone of this
Document".  What does this mean and is this
useful to me?  If so, how do I use it because:

            SAXBuilder builder = new SAXBuilder();
            // Create the document
            Document doc = builder.build(new File(filename));
	      Document doc2 = doc.clone();

doesn't compile.  Also scrutinized my copy of "Java and XML" and didn't find
anything.

Regards,

Brad Morgan
e-Publishing Corp.

Email: Brad.Morgan at e-pubcorp.com
Phone: (719)593-7377 x35
Fax: (719)593-2996

e-Publishing Corp. is a BroadVision company
NOTICE: This message is intended only for the use of the Addressee and may
contain information that is PRIVILEGED and CONFIDENTIAL. If you are not the
intended recipient, dissemination of this communication is prohibited. If
you have received this communication in error, please erase all copies of
the message and its attachments and notify us immediately.






More information about the jdom-interest mailing list