Re: Converting elements from a SAX stream to JDOM elements
Tatu Saloranta <[email protected]>
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <[email protected]> |
--- On Sat, 7/18/09, Colin Horne <[email protected]> wrote: > From: Colin Horne <[email protected]> > Subject: [jdom-interest] Converting elements from a SAX stream to JDOM ... > > I have a long (infinite) XML stream, which I intend to parse with SAX. > Each individual element in the stream is small, and should > be parsed with JDOM: > > <stream> > <element>...</element> > <element>...</element> > </stream> > > So each <element> (and their children) are parsed with JDOM, but the > <stream> as a whole is parsed with SAX. It would be ... Do you absolutely have to use SAX for parsing here? This is a rather typical case where STAX API works well for parsing. Since you control traversal over input, it is easy to pass Stax XMLStreamReader for whoever builds JDOM trees, sub-tree by sub-tree. For what it's worth, I wrote such a build a while ago: http://docs.codehaus.org/display/WSTX/StaxMisc and submitted it for JDOM. Not sure if it's included anywhere (under contribs, maybe). Hope this helps, -+ Tatu +- ps. There are also plans to include this functionality in StaxMate [http://staxmate.codehaus.org] (issue [http://jira.codehaus.org/browse/STAXMATE-9])-- 2.0 has equivalent for DOM trees, but no JDOM support yet. _______________________________________________ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/[email protected]