[jdom-interest] Error handling

Scott Ellis scotey at pacbell.net
Mon Jan 3 11:32:49 PST 2005


Thanks for both replies.  detach() does the trick.

Scott
----- Original Message ----- 
From: <kjohnson at spicer.com>
To: <scotey at pacbell.net>; <jdom-interest at jdom.org>
Sent: Monday, January 03, 2005 7:52 AM
Subject: RE: [jdom-interest] Error handling


> 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
>
> All,
>
> I have an xml document that contains a root node and several children as
> such:
>
> <RootNode>
>     <ChildNode>
>     <ChildNode>
>     ...
> </RootNode>
>
> 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
> directory.
>
> 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 );
>
> Help?
>
> Thanks,
> Scott
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>




More information about the jdom-interest mailing list