[lxml-dev] relax ng bug: validation twice doesn't give same answer

Hi there, We just ran into the following problem with lxml's RelaxNG validation. Validating with the same RelaxNG schema gives the right result (invalid). Validating again however gives valid! This script is a minimal test case that demonstrates the problem. Tested with lxml 1.1.2 and libxml2 2.6.24 and also 2.6.26 on another machine. From an earlier thread last year it's possible that this is a libxml2 bug: http://codespeak.net/pipermail/lxml-dev/2005-September/000423.html This was more than a year ago though and it's somewhat surprising this still wasn't fixed. I found the bug report: http://bugzilla.gnome.org/show_bug.cgi?id=315883 and have added something to it in the hope it'll spur some activity in confirming it... Regards, Martijn from lxml import etree from StringIO import StringIO v = etree.RelaxNG(etree.parse(StringIO('''\ <?xml version="1.0" encoding="UTF-8"?> <grammar ns="http://some.namespace.org" xmlns="http://relaxng.org/ns/structure/1.0"> <start> <element name="root"> <element name="sub"><text/></element> </element> </start> </grammar> '''))) # this is an invalid document d = etree.parse(StringIO('''\ <root xmlns="http://some.namespace.org"> <sub><something /></sub> </root>''')) first = v.validate(d) # returns 0, what is expected second = v.validate(d) # returns 1! assert first == second, "Validity isn't the same over time"
participants (1)
-
Martijn Faassen