Lists Home |
Date Index |
John Cowan wrote:
> Simon St.Laurent scripsit:
> > My own MOE (http://moe.sourceforge.net) is an effort to blur the push
> > model and the tree-based model, since MOE objects can listen to the
> > events and build trees as desired. Perl and Python have libraries for
> > this as well.
> I have just proposed on the xom-interest list an XMLFilter called Shemp :-)
> which does the same general thing with SAX events and XOM trees. During a
> startElement callback, Shemp's client can ask it to start creating a tree;
> all SAX events are then consumed until (but not including) the matching
> endElement callback, at which time the tree is available.
there are already such ultra lightweight XML trees. i have implemented
XmlPullNode which is incremental document object model essentially
blending streaming-and-forward-only (events) and
represent-xml-in-memory (trees) approaches.
using XmlPullNode you can start accessing XML tree _before_ XML input
is fully available (as soon as you try to read anything that is not available
tree node is expanded by pulling more input). there are basically two
ways to use XmlPullNode: you can ignore that it is constructed on demand
and use it as any other "DOM" or you can actually access underlying xml
pull parser and read input directly (to avoid construction of node tree
for parts of input). parts of tree that are no longer needed can be removed
and it helps to parse even huge inputs in small memory footprint.
XmlPullNode is part of XPP2 - a bit old and mostly deprecated
by XPP3 and XmlPull API but it is still working just fine (and is well tested).
now i am working on on new version that will be part of XPP3
and will have more user friendly API: XPP2 version is
efficient but is no toot good about forgiving or catching user errors ...
approaches like XmlPullNode have obvious advantages of
giving full navigation and still maintaining efficient resource
utilization but i still wonder if anything better than incremental
XML tree can be used that is between SAX and DOM: as easy
to navigate as DOM and as fast and low on memory as SAX ...