[XML-SIG] Proposal: Marrying SAX2 and DOM
21 Feb 2000 10:21:14 -0600
As SAX2 comes near to being finalized, I'd like to make a proposal for
the Python binding that could make SAX2/Python a lot simpler. SAX2
adds support for specifying "features" that the parser supports. Many
of these features include additional properties be made available to
handlers. In the Java binding these additional properties are only
available through "callbacks" to the parser.
What I would like to propose is that the Python SAX2 binding pass
objects, specifically DOM-conformant objects, as a single parameter
rather than using both positional parameters and callbacks.
* Will allow additional properties to be passed to handlers in a
straightforward way, making parser extensions and filters much
simpler to use and implement.
* Becomes much easier using SAX to traverse a DOM, each SAX event
simply passes the DOM node itself, rather than having a domNode()
callback on the "parser".
* A wider gap between the Java binding and the Python binding.
* Creating objects for each event is a performance hit.
The parser would most likely use a DOMFactory specific to the type of
DOM objects the user would want, MiniDOM, PyDOM, etc. If the parse is
being used simply to create a DOM tree, then the DOM objects passed in
the events can be used to create the tree (by just appending children
to their parent).
This pattern has been used in the Perl SAX binding and I've found it
to be extremely convenient. I would propose using DOM nodes for SAX2
(Java) altogether for the same reasons, but I think Java's strict
typing would be very prohibitive to this sort of idea.