[jdom-interest] Merging JDOM documents
Rosén Håkan
hakan.rosen at kvadrat.se
Tue Oct 7 23:57:37 PDT 2003
Hi, thanks for answering !
My problem remains, cloning effects the origin document.
I'd rather like to make a copy of my second document,
is there a nice way to make a deep-copy of an Element ?
regards
-----Original Message-----
From: Per Norrman
To: 'Rosén Håkan'; jdom-interest at jdom.org
Sent: 2003-10-07 17:15
Subject: SV: [jdom-interest] Merging JDOM documents
Hi,
what did you expect when you detached the root
element from the document?
You must either clone the element
inReport.getRootElement().getChild("employee").addContent
(Element)(rules.getRootElement().clone());
or, if concurrency is not an issue, save a reference
to the detached element and after finishing
the process, detach it from the first document and set
it back as root element in the second.
/mvh
Per Norrman
> -----Ursprungligt meddelande-----
> Från: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org] För Rosén Håkan
> Skickat: den 7 oktober 2003 16:05
> Till: 'jdom-interest at jdom.org'
> Ämne: [jdom-interest] Merging JDOM documents
>
>
> Hi,
> I'm trying to merge two documents and then transform them
> into a result.
>
> some code:
> public Document setReports(Document inReport, Document rules)
> throws Exception {
> // insert incoming rules into inReport
> inReport.getRootElement().getChild("employee").addContent
> (rules.getRootElement().detach());
> Transformer transformer = TransformerFactory.newInstance().
> newTransformer(new StreamSource("prepare.xsl"));
> JDOMSource source = new JDOMSource(inReport);
> JDOMResult result = new JDOMResult();
> transformer.transform(source, result);
> return result.getDocument();
> }
>
> The Document 'rules' is stored in my a servletContext and
> only read once, The code works fine the first time, but the
> second time I get an error that the root element is not set.
> please help regards
> /Håkan
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com
More information about the jdom-interest
mailing list