[jdom-interest] Merging JDOM documents

Rosén Håkan hakan.rosen at kvadrat.se
Tue Oct 7 07:04:31 PDT 2003


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



More information about the jdom-interest mailing list