[lxml-dev] Validation against an external DTD
Lee Brown
lee.brown at elecdev.com
Wed Feb 7 15:45:20 CET 2007
Greetings!
I do not know if lxml can load a DTD from an external file. And the docinfo
attributes on the etree instance are read-only, so there's no help there.
As a workaround, though, you might be able to prepend a DOCTYPE string to the
beginning of the file before you parse it.
-----Original Message-----
From: lxml-dev-bounces at codespeak.net [mailto:lxml-dev-bounces at codespeak.net] On
Behalf Of Michael Guntsche
Sent: Tuesday, February 06, 2007 4:21 PM
To: lxml-dev at codespeak.net
Subject: Re: [lxml-dev] Validation against an external DTD
On Feb 6, 2007, at 9:52 PM, Lee Brown wrote:
>
> class XMLParser(_BaseParser)
> | The XML parser. Parsers can be supplied as additional argument to
> | various parse functions of the lxml API. A default parser is
> always | available and can be replaced by a call to the global
> function | 'set_default_parser'. New parsers can be created at any
> time without a | major run-time overhead.
I had a look at this as well, but I do not understand, how I specify the DTD
that should be used for validation. I unterstand that the Parser validates
against a DTD if it is specified in the XML file and found by the parser during
execution. But in my case I need something like this
PyXML example:
dtd = xmldtd.load_dtd("my dtd file")
parser = xmlproc.XMLProcessor()
parser.set_application(xmlval.ValidationApp(dtd, parser)) ....
parser.parse_file("my xml file that needs to be validated")
Kind regards,
Michael
_______________________________________________
lxml-dev mailing list
lxml-dev at codespeak.net
http://codespeak.net/mailman/listinfo/lxml-dev
More information about the lxml-dev
mailing list