[XML-SIG] Proposal: Marrying SAX2 and DOM

Ken MacLeod ken@bitsko.slc.ut.us
14 Mar 2000 11:36:54 -0600

[I'm replying seperately to "marrying SAX2 and DOM" and "full XPath
callbacks".  This message is about "marrying SAX2 and DOM".]

Paul Prescod <paul@prescod.net> writes:

> Here are the basic ideas:
>  * handlers pass DOM nodes. (a la "Marrying" and Pyxie)
>  * all parent nodes are available (not really that expensive usually)
>  * peer and child nodes are not typically available
>  * handles namespaces

One reason for marrying SAX and DOM right in the SAX binding, rather
than pushing it up to a "higher level" (into a downstream SAX filter,
for example) is that then _all_ SAX modules are working at the same
level, better sharing of code and network effect.

To have some set of modules work with DOM nodes and other sets of
modules work with positional parameters would involve inserting
filter/converters between each different kind in a SAX chain.  The
worst of which is that you'd probably lose any attachment to the DOM
nodes generated at the head of the stream (especially a DOM-walker).

OTOH, note that this will be _required_ to work with Java-based SAX
classes unless we can convince _them_ to marry SAX and DOM (which,
with one dip of the toe in that water, doesn't seem likely before
SAX3).  One could use a Java SAX parser/generator to generate events,
and then filter into a DOM-node builder, and then use DOM-nodes in
subsequent handlers, but if you wanted to use Java SAX filters or
handlers you'd still need to insert converters.

One hope that I have is that marrying DOM and SAX in Perl, and still
hopefully, in Python, will show that this is actually the best thing
for SAX overall (SAX3).

The strongest argument against DOM in SAX is "heavyweight" DOM (in
Java).  Where's Java's equivalent of "mini-DOM" or a lightweight DOM?

  -- Ken