[lxml-dev] Validating against an external DTD
Hello, 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. Is support for this planned as well or should I stick to using DTD.validate()? I would prefer an exception though. Kind regards, Michael PS: THANK you once again for adding this. If everything works out, I will remove pyxml completely from my application in the near future.
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
participants (2)
-
Michael Guntsche
-
Stefan Behnel