[jdom-interest] multiple xml files - one Document object
Jon Baer
jonbaer at digitalanywhere.com
Tue Nov 27 07:13:39 PST 2001
Actually I don't think there is a Document.addContent(Element) method (is there?). I
think you need to add it to the root of d0 instead, something probably like:
public static void main(String[] args) {
SAXBuilder b = new SAXBuilder();
Element root = new Element("all");
Document mainDoc = new Document(root);
try {
Document one = b.build("sql1.xml");
root.addContent(one.getRootElement().detach());
Document two = b.build("sql2.xml");
root.addContent(two.getRootElement().detach());
Document three = b.build("sql3.xml");
root.addContent(three.getRootElement().detach());
XMLOutputter out = new XMLOutputter();
out.output(mainDoc, System.out);
} catch (Exception e) {
e.printStackTrace();
}
}
Ian Lea wrote:
> Something like this might do the trick:
>
> Document d0 new Document(new Element("allSQL"));
> d0.addContent(getSQL("sql1.xml"));
> d0.addContent(getSQL("sql2.xml"));
> ...
>
> Element getSQL(String name) {
> Document d = new SaxBuilder().build(name);
> return d.getRootElement().detach();
> }
>
> --
> Ian.
> ian.lea at blackwell.co.uk
>
> > Carey Boldenow wrote:
> >
> > In our application, we have many xml documents that contain our SQL
> > statements. However, upon application initialization, we would like to parse
> > all these files and then store all the elements in one Document instance. If
> > it matters, each of the xml files has the same DTD. Is there anyway to do this
> > using JDOM along with the Parsers to do this?
> >
> > Thanks for any help!
> >
> > Carey Boldenow
> _______________________________________________
> 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