[lxml-dev] Validating against an external DTD
Stefan Behnel
stefan_ml at behnel.de
Mon Feb 26 20:38:05 CET 2007
Hi,
Michael Guntsche wrote:
> I just noticed that lxml has DTD-validation against external DTDs now
> in trunk YAAAAAAAAAAYYY. Thank you, thank you, thank you.
:)
> I played around a little bit with it and noticed that assertValid is
> not working correctly.
Ah, what?
>>> root = etree.XML("<b><a/></b>")
>>> dtd = etree.DTD(StringIO("<!ELEMENT b EMPTY>"))
>>> dtd.assertValid(root)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "etree.pyx", line 1885, in etree._Validator.assertValid
etree.DocumentInvalid: Document does not comply with schema
The docstring of assertValid() says:
"Raises DocumentInvalid if the document does not comply with the schema."
So, how's that not working? Or were you expecting it to behave like
"dtd.assert_()"?
Stefan
More information about the lxml-dev
mailing list