[jdom-interest] Error handling

kjohnson at spicer.com kjohnson at spicer.com
Mon Jan 3 07:52:22 PST 2005

Try using clone() or detach() on parsedElemFromOriginalDocument.

-----Original Message-----
From: Scott Ellis [mailto:scotey at pacbell.net] 
Sent: Monday, January 03, 2005 1:17 PM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Error handling


I have an xml document that contains a root node and several children as


I parse this document, iterate the children, then attempt to apply ChildNode
to the database.  If there are any problems with the processing of ChildNode
to the database due to any SQL error, I create another document that has the
same structure, but contains only the ChildNode elements for which problems
occurred.  Then I write this new document to the file system in an error

This used to work, but it seems now that I changed something that is giving
me a problem.  The error reads something like  -- The Content already has an
existing parent "RootNode" --

I know the reason is that the ChildNode is already parsed and has an
existing parent from the parsed document, and that the new parent I am
creating has the same named parent, the question is how to get around it.

I create the document like this:

Element root = new Element( "RootNode" ); Document doc = new Document( root
); root.addContent( parsedElemFromOriginalDocument );



To control your jdom-interest membership:

More information about the jdom-interest mailing list