[jdom-interest] Re: building a large xml file

Joseph Bowbeer jozart at csi.com
Thu Feb 22 19:27:20 PST 2001


Another option is to use the SAX-based XMLWriter in jdom/samples
( Adapted from David Megginson's DataWriter @ megginson.com )

http://cvs.jdom.org/cgi-bin/viewcvs.cgi/jdom/samples/sax/XMLWriter.java


    XMLWriter xml = new XMLWriter(writer);
    xml.startDocument();
    xml.startElement("", "RootElement", "", rootAtts);
    while (!done) {
        xml.emptyElement("Row",  rowAtts);
    }
    xml.endElement("RootElement");
    xml.endDocument();

You may also find the dataElement method in XMLFilterBase useful.

XMLWriter gives you SAX-level control over the output.  You will however
also need to construct the attributes using SAX.

    AttributesImpl atts = new AttributesImpl();
    atts.addAttribute("", name, "", "CDATA", value);
    ...


---- original message -----

From: "Matthew MacKenzie" <matt at xmlglobal.com>
To: "Mirko Wolf - CBS" <wolf at cbsweb.net>
Subject: RE: [jdom-interest] building a large xml file
Date: Thu, 22 Feb 2001 08:04:34 -0800

Mirko,

Two Options:

1. Use StringBuffers and build the xml yourself as you process the lines,
or
2. Build a org.jdom.Element for each line and output it when processing
that line is complete using org.jdom.outputter.XMLOutputter.


-----Original Message-----
From: Mirko Wolf - CBS
Sent: February 22, 2001 7:07 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] building a large xml file

I've a flat file containing aprox 30000 lines with 100 fields each line.
Every field refers to a  xml-tag. I'm not sure, if my application can
handle the hole data at once, so i would read a single line from the
file, convert it and write it as part to my output xml-file. Is this
possible?
Are the other solutions to handle such large data?




More information about the jdom-interest mailing list