Hi, just noticed that namespace handling in child element access does not work correctly (any more) if the parent element is in no-namespace:
from lxml import etree, objectify print "etree.__version__:", etree.__version__ etree.__version__: 2.3.5 print etree.LIBXML_VERSION (2, 7, 8) objectify.enable_recursive_str() root = objectify.fromstring(""" ... <root> ... <foo:x xmlns:foo="/foo/bar">1</foo:x> ... <x>2</x> ... </root>""") print root root = None [ObjectifiedElement] {/foo/bar}x = 1 [IntElement] x = 2 [IntElement] print "root.x:", root.x root.x: 1 assert root.x == 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> AssertionError
As root lives in no-namespace root.x should return the second, no-namespace x child element. This worked correctly up to ~2.0 (based on libxml 2.6.27) and stopped working for ~2.1.5 (libxml 2.6.32), judging from the versions I have tried. Funny that we never noticed it up to now. Not too much insane namespace mixing going on here, obviously ;-)
from lxml import etree, objectify print "etree.__version__:", etree.__version__ etree.__version__: 2.0.alpha4 print etree.LIBXML_VERSION (2, 6, 27) objectify.enableRecursiveStr() root = objectify.fromstring(""" ... <root> ... <foo:x xmlns:foo="/foo/bar">1</foo:x> ... <x>2</x> ... </root>""") print root root = None [ObjectifiedElement] {/foo/bar}x = 1 [IntElement] x = 2 [IntElement] print "root.x:", root.x root.x: 2 assert root.x == 2
Btw this works correctly if the parent element is in a namespace, which is the case the documentation shows (and doctests). Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart