namespace inconsistency with attributes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
scoder |
Bug Description
here is a python session showing a namespace inconsistency (from my
point of view). It seems that a roundtrip (reading and
saving a xml document ) is not possible with lxml under this
circumstances. Maybe there is a misunderstanding on my side.
user at workstation:~/tmp$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml.etree as et
>>> eTree=et.
... <bla xmlns="urn:ns1"
... xmlns:o="urn:ns2"
... xmlns:ns1="urn:ns1"
... >
... <bluff ns1:val="abc"/>
... </bla>
... """)
>>> bluff=eTree.
>>> print bluff.attrib[
abc
>>> bluff.attrib[
>>> print bluff.attrib[
def
>>> #so far everything went well
>>> ts=et.tostring(
>>> print ts
<?xml version='1.0' encoding='UTF-8'?>
<bla xmlns="urn:ns1" xmlns:o="urn:ns2" xmlns:ns1=
<bluff val="def"/>
</bla>
>>> # val="def" --> attribute namespace was
>>> # lost because of default namespace ?
>>> eTree=et.
>>> bluff=eTree.
>>> print bluff.attrib[
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "lxml.etree.pyx", line 1893, in lxml.etree.
(src/lxml/
KeyError: '{urn:ns1}val'
>>>
it seem that all versions of lxml have this feature (e.g. 2.2.1) and libxml 2.7.2
Changed in lxml: | |
assignee: | nobody → Stefan Behnel (scoder) |
importance: | Undecided → Medium |
milestone: | none → 2.3 |
status: | New → Confirmed |
Fix implemented in trunk rev. 70310:
https:/ /codespeak. net/viewvc/ ?view=rev& revision= 70310