It would be very very odd if you would load a DTD in variable 'p', not use that variable in any way and python will magically know that that is the DTD you want to validate with. /usr/bin/env python from xml.parsers.xmlproc import xmlproc from xml.parsers.xmlproc import xmlval from xml.parsers.xmlproc import xmldtd def validate_xml(xml_filename, dtd_filename): """Validate a given XML file with a given external DTD.If the XML file is not valid, an error message will be printed to sys.stderr, and the program will be terminated with a non-zero exit code. """ dtd = xmldtd.load_dtd(dtd_filename) parser = xmlproc. Validating App(dtd, parser)) = dtd = dtd # If you want to override error handling, subclass # xml.parsers.xmlproc.xmlapp.This work is distributed under the terms of Perl's Artistic License.

All code examples in these files are hereby placed into the public domain.

You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit.

Abstract This document aims to provide answers to questions that crop up regularly on the 'perl-xml' mailing list.

The above recipe provides pretty much all the information you need to know for doing this.

Users will want to "round out" the implementation of My App (or any other subclass of xmlproc.

Application) to perform "application specific" parsing per their particular needs.

Python will find that DTD itself and load it to validate your XML file.

The xmlval and xmldtd modules let you validate XML docs against an external DTD file.

This is a simple, straightforward recipe that illustrates how to use the xmlval and xmldtd modules for validated XML parsing.

Documentation on xml parsing in general, and xmlproc in particular, is easy enough to come by.

However, I had to dig around a bit to find out how perform validated parsing (against an external DTD) using xmlval and xmldtd.