[XML-SIG] xmlproc, dtd's, and such
Lars Marius Garshol
07 Jun 1999 07:57:11 +0200
* Dan Libby
| Okay, so I'm using xmlproc for some DTD based validation. However,
| I don't want to go off to the network every time I have to validate
| a new file, which means I will have to cache locally somehow.
Basically, what determines where xmlproc will look for the DTD is the
document itself and the public and system identifiers in the DOCTYPE
If you set those correctly, xmlproc will look for the DTD where you
want. You can also use a catalog file to control the resolution of the
public identifier, but in SAX 1.0 there is no standard way to give the
parser a pointer to the catalog file.
If you don't trust the system and public identifiers and want to
control this yourself you can use the EntityResolver interface.
Here's an example:
from xml.sax import saxexts
def resolveEntity(self, publicId, systemId):
print "PUBID: "+`publicId`+"\tSYSID: "+`systemId`
The first call to resolveEntity will be for the external DTD subset
and if you want to control where that is read from, just return the
system identifier you want to use.
(If you want to use a catalog file in a standard way at the moment,
this is how. xmlproc comes with a SAX EntityResolver which reads and
uses a catalog file.)
I hope this helped,