SAX and DTDs

Alin Dobre <[email protected]>
Newsgroups gmane.comp.python.xml
Organization Gentoo Foudation/Gentoo.RO Community
Message-ID <[email protected]>
  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/
_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.