[lxml-dev] Validation against an external DTD
Stefan Behnel
stefan_ml at behnel.de
Wed Feb 7 19:37:02 CET 2007
Hi,
Lee Brown wrote:
> 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.
lxml does not currently have support for adding/updating DTD subsets, though
we already had a couple of requests to make this work - patches are very welcome.
> As a workaround, though, you might be able to prepend a DOCTYPE string to the
> beginning of the file before you parse it.
No guarantee, but that should generally work.
Stefan
> -----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
>
> _______________________________________________
> lxml-dev mailing list
> lxml-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/lxml-dev
More information about the lxml-dev
mailing list