[jdom-interest] SubDocuments

Ken Rune Helland kenh at csc.no
Thu May 16 11:00:48 PDT 2002


> I have inherited a system that uses JDOM documents for the navigation. 
>  I am trying to upgrade to b8 but the way we use the documents is an 
> issue.  Is it possible in b8 to use an Element from an existing
> Document  to create a new Document?  Anybody know why this worked in b6
> and, I  think, b7?  I would like to be using this library correctly but
> I also  don't want to rewrite my entire navigation subsystem.  The
> error that  occurs from when I do:
> 
> new Document(anElementFromAnotherDocument);
> 
> is of course that it already has an existing parent.
> 
> Basically, navigation is determined by an "activity" xml and each 
> element directly under the root is a Tab in the GUI.  When a Tab is 
> clicked the navigator takes the Tab Element and creates a new Document 
> that becomes the navigation for the GUI.  

Use: new Document((Element)anElementFromAnotherDocument.clone());
If you want the other document to remain intact.

Or: new Document(anElementFromAnotherDocument.detacth());
if you dont care about the other document anymore and woud like to save
some memory and cpu cycles.


KenR







More information about the jdom-interest mailing list