Using an DTD not specified in XML file for validation

Brian Quinlan brian at sweetapp.com
Wed Aug 6 19:21:37 CEST 2008


Hey,

I'm trying to figure out how I can validate an XML file using a DTD that 
isn't specified in the XML file.

My code so far is:

from xml import sax
from xml.sax import sax2exts

parser = sax2exts.XMLValParserFactory.make_parser()

parser.setContentHandler(handler)
parser.setErrorHandler(handler)

parser.parse(xml_file)

And this works fine if the DTD is specified in the XML file i.e errors 
are generated for non-compliant entities. But I would like to force the 
file to be valid according to one other DTD file that is not referenced 
in the XML file.

Anyone know how to do this?

Cheers,
Brian



More information about the Python-list mailing list