[XML-SIG] Writing SAX-drivers

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Fri, 9 Nov 2001 11:36:36 +0100 (CET)


On Fri, 9 Nov 2001, M.-A. Lemburg wrote:

> Thank you very much for all the details ! I appreciate your
> help.
> 
> Now I will just have to wrap my head around this ...

Feel free to ask if you encounter problems. 

A quick way of testing your parser is:

from xml.dom.ext.reader import Sax2
def load_to_dom(filename):
    parser = MySax2Parser()
    reader = Sax2.Reader(0, 0, None, Sax2.XmlDomGenerator, parser)
    stream = open(filename,'r')
    d =  reader.fromStream(stream,ownerDoc)
    return d

You can then PrettyPrint the result to see if it looks like expected. 

Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).