[XML-SIG] SAX and DTDs

Alin Dobre alin at gentoo.org
Thu Aug 4 11:39:57 CEST 2005


  Hey list,

I have a python script that does a simple parsing of a XML document
using SAX. The problem is that I cannot get to validate the XML using an
external DTD file.

------------
#!/bin/env python
import sys
from xml.sax import saxlib, saxexts
class mySaxDH(saxlib.HandlerBase):
  def startDocument(self):
    print 'Document start'
handler = manSaxDH(sys.stdout)
parser = saxexts.make_parser()
parser.setDocumentHandler(handler)
inFile = file(sys.argv[1], 'r')
parser.parseFile(inFile)
inFile.close()
------------
<?xml version="1.0"?>
<!DOCTYPE man SYSTEM "my.dtd">
<tag>data</tag>
------------

For the examples shown above, I want to validate the xml stream against
the my.dtd file. Any idea how to do this using SAX?

Thanks,
Alin.
-- 
Alin DOBRE
Romanian Lead Translator
Gentoo Documentation Project: http://www.gentoo.org/doc/en/
Gentoo.RO Community:          http://www.gentoo.ro/


More information about the XML-SIG mailing list