[XML-SIG] [ Newbie ] Parsing XML with an external DTD

Martin v. Loewis martin@v.loewis.de
Tue, 6 Nov 2001 00:06:44 +0100


> <?xml version='1.0' encoding='ISO-8859-1' standalone="yes"?>
> <MONDOC>
>     <MONDATA>Blah blah</MONDATA>
> </MONDOC>
> 
> With a dtd... How can i do that without writing the dtd link into the
> document ?

You don't need to put a link to the DTD into the document. It is also
possible to put the entire DTD into the document, into the "internal
subset" (i.e. the [...] block).

> Can i set the DTD to use to the validating parser ?

With xml.parsers.xmlproc, I believe this is possible. You need to use
xmldtd.load_dtd[_string] to create a DTD object. Then you create a
xmlval.XMLValidator, passing the DTD. Unfortunately, due to a bug,
this appears not to be possible - you should add support for passing a
DTD that way by modifying your copy of PyXML. Finally, you can parse
the document using the XMLValidator.

HTH,
Martin