[XML-SIG] XMLFilterBase examples?

Martin v. Loewis martin@v.loewis.de
07 Aug 2002 20:18:04 +0200


James Christensen <jmlchristensen@yahoo.com> writes:

> What I want to do and what I really like about SAX
> processing is setting up multiple discrete filters
> that take in a stream of sax events and produce a
> stream of sax events. I suppose this is possible in
> python, but I have to admit it's not immediately
> obvious to me how to achieve this. I suppose part of
> the problem is that I'm not quite clear on the proper
> way to write a handler that's not just a sax event
> sink. 

You should inherit from xml.sax.saxutils.XMLFilterBase. This is
essentially a XMLReader which is initialized with another XMLReader
(its parent). You can then use the filter in place of the original
reader.

The filter installs itself as a handler for everything, forwarding
everything to the application's handler, and forwards everything from
the application to the reader. You can override the events you are
interested in.

HTH,
Martin