[jdom-interest] Couple of issues I need help on, (memory, sax vs dom, etc)
bob mcwhirter
bob at werken.com
Thu Jul 18 12:49:08 PDT 2002
> 3) Sax vs Dom:
Here's how it typically works:
1) sax-parser reads a file/stream.
2) it spews SAX events.
3) A handler reads the events, and builds an object-model.
It works like that if you're using Xerces to build a DOM or
if you use SAXBuilder to build a JDOM.
In both cases, there's a handler somewhere converting events
into a navigable object model.
If you were to use DOMBuilder, the process would be:
1) sax-parser reads a file/stream.
2) it spews SAX events.
3) A handler reads the events, and builds a DOM object-model.
4) DOMBuilder walks the DOM object-model, and creates a JDOM
that mirros the DOM.
So, instead of SAX -> DOM -> JDOM, just go SAX -> JDOM.
If you want to process large files, and can do so in a sequential
mannner, dom4j's[1] ElementHandler interface is darn nice. You can
process a -subtree- and detatch it for garbage collection. Somewhat
a hybrid between events and an object-model.
-bob
[1] http://dom4j.org/
More information about the jdom-interest
mailing list