[jdom-interest] Merging jdoms

Noam Tamim noamt at yahoo.com
Wed May 9 06:46:48 PDT 2001


----- Original Message -----
From: "Jason Hunter" <jhunter at acm.org>
To: "Heather Boyd" <hlb at aspectgroup.co.uk>
Cc: <jdom-interest at jdom.org>
Sent: Tuesday, May 08, 2001 20:06
Subject: Re: [jdom-interest] Merging jdoms

> > Document doc = new Document(new Element ("NEW"));
> > Element root = doc.getRootElement();
> > Document doca =  JDomFromAnOtherSource()
> > Element a = doc.getRootElement();
> > root.addContent(a)
> Call a.detach() to remove "a" from its document before adding it to
> another document.

Is it possible for Element.addContent(Element elt) to do something like
this?

if (elt.getParent() != null) {
    elt.detach();
}
// go on with adding elt

Or, alternatively, make it throw an exception when trying to do that.


 - Noam.







More information about the jdom-interest mailing list