[XML-SIG] handle drv_xmlproc_val SAXParseExceptions
Remy C. Cool
dev-xml@smartology.nl
Thu, 5 Dec 2002 22:00:36 +0100
On Thursday 05 December 2002 18:11, Martin v. Löwis wrote:
> I recommend that you abandon SAX, in favour of SAX2. The SAX
> libraries are maintained in PyXML only for backwards compatibility,
> and no corrections are likely made for errors. With SAX2, things
> may work out of the box; if not, please submit a bug report (or,
> better yet, a fix).
I've changed the code to:
from xml.sax.handler import ContentHandler, ErrorHandler, DTDHandler,
EntityResolver
class xpdf_parser:
...
...
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces, feature_validation
if __name__ == '__main__':
# create a parser
parser = make_parser('xml.sax.drivers2.drv_xmlproc')
# tell the parser we are not interested in XML namespaces
parser.setFeature(feature_namespaces, 0)
# tell the parser we want dtd validation
parser.setFeature(feature_validation, 1)
# create the handler
pdf = xpdf_parser()
# tell the parser to use our handler
parser.setContentHandler(pdf)
parser.setErrorHandler(pdf)
parser.setDTDHandler(pdf)
# Parse the input
parser.parse(xpdf_file)
This is SAX2 correct ?
I also 'fixed' the DTD and the DTD warnings are gone ... but the
TypeError remains. I'll look into the code, but if someone, who is
more experienced with this module knows the answer .... please help
me conserve some time.
Kind Regards,
Remy