[lxml-dev] Bug: type annotation namespace-prefix goes missing

Stefan Behnel stefan_ml at behnel.de
Thu Feb 7 17:45:02 CET 2008


Hi,

Christian Zagrodnick wrote:
> Note the last <text node where it says pytype instead of py:pytype.
> 
> I think is has something todo with the xpath, but I cannot really 
> figure out what.
> 
> That's with lxml 2.0 and python 2.4

it's not related to XPath, it's just that you change the order of the children
in your test:

-------------------------
import lxml.etree
import lxml.objectify

xml = lxml.objectify.XML(
    '<a xmlns:py="http://codespeak.net/lxml/objectify/pytype">'
    '<b name="b1"><title py:pytype="str">tit</title><text>foo</text></b>'
    '<b name="b2"><text>bar</text></b></a>')

print lxml.etree.tostring(xml, pretty_print=True)

foo = xml['b'][0]
bar = xml['b'][1]
foo['text'] = 'FOO!'

print lxml.etree.tostring(xml, pretty_print=True)

foo = xml['b'][0]
bar = xml['b'][1]
xml['b'] = [bar, foo]

print lxml.etree.tostring(xml, pretty_print=True)
-------------------------

gives the same result. I don't even think it's related to objectify.

I'll look into it when I find the time.

Stefan


More information about the lxml-dev mailing list