[jdom-interest] A Fast Way to Merge Documents

Jason Hunter jhunter at collab.net
Fri Dec 15 00:16:06 PST 2000


To move the doc2 root as a child to the doc1 root:

Element doc2root = doc2.getRootElement();   // get pointer to it
doc2.removeContent(doc2root);               // take it from one tree
doc1.getRootElement().addContent(doc2root); // add to another tree

Easy and fast.

-jh-

Aleksi Kallio wrote:
> 
> We read stuff from database to JDOM Documents and then merge them together to make content of a web-page (through XSLT-translation).
> 
> We use
>     doc1.getRootElement().addContent(doc2.getRootElement().getCopy("doc2"));
> 
> to merge documents. This seems to be very slow (because of copying?).
> 
> What would be the FAST way to combine two documents? After all, it could be just changing a few references. The answer could also be a bit of hack...
> 
> Are there any articles or references to JDOM performance issues?
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list