[jdom-interest] JDOM w/ *long* streams

Jason Hunter jhunter at acm.org
Tue Aug 8 09:48:59 PDT 2000

"Daniel L. Rall" wrote:
> Excuse the newbie question, it may just demonstrate the fact that I
> don't know a whole lot about DOM (yet).  :)

Hi dlr, small world.

> I am curious as to how well JDOM will handle the parsing of 
> records from
> an extremely long data stream (10+ MB).  I would like to parse nodes
> containing good sized DOM trees starting one level deep from the root
> element.  Will JDOM need to read the entire stream before 
> giving access
> to second level nodes 

With our current builders, yes, because we use SAX to read the document
and construct the JDOM tree based on the SAX events.  It's been a goal
since the beginning to support a deferred builder, one that parses only
what's necessary and stores offsets instead of data.  We'll probably use
weak references so even already parsed data can be reclaimed as
necessary, then rebuilt later if needed using the indexes.  That's not
something I'm worrying about now though.  Gotta finalize 1.0 first.

For what you want SAX may be the best option.  Or you could write a
custom builder (and a custom Element subclass) that read the tree only
as necessary.  Just implement lazy get methods that call for more
parsing if they don't have the info they need.  It wouldn't be the
special purpose deferred builder we envision, but it would be fairly
easy to implement.


More information about the jdom-interest mailing list