[XML-SIG] Switching back and forward between SAX and DOM

Uche Ogbuji uche.ogbuji@fourthought.com
Thu, 06 Jun 2002 08:01:50 -0600


> Just a Python newbie question to try to find my way into XML processing 
> with Python :-)
> 
> In Java, I like to use both SAX and DOM (I prefer using SAX to bind 
> documents to and from predefined data models and DOM when manipulating 
> documents) and I need|want to do the same with Python (I am currently 
> using Python 2.2 with 4suite 0.12 latest CVS).
> 
> How can you get a DOM tree out of SAX events (if for instance you've 
> developed a ContentHandler, can you retrieve a part of the document as a 
> DOM tree by forwarding the events to a DOM parser?) and vice versa, how 
> can I serialize a DOM tree as SAX events which can be processed by a 
> ContentHandler?

The basic infrastructure for both tasks is available, but largely not ported 
to the Domlettes, which I know you're using.  They use the older interfaces 
that you struggled with at first.

I'll do a bit of checking today to see how much porting would be required to 
get what you need.  These would actually be very good general-purpose 
additions to Ft.Xml.Util, and updates to xml.dom.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Track chair, XML/Web Services One (San Jose, Boston): 
http://www.xmlconference.com/
DAML Reference - http://www.xml.com/pub/a/2002/05/01/damlref.html
The Languages of the Semantic Web - http://www.newarchitectmag.com/documents/s=
2453/new1020218556549/index.html
XML, The Model Driven Architecture, and RDF @ XML Europe - 
http://www.xmleurope.com/2002/kttrack.asp#themodel