Attribute names ignore namespaces
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
scoder |
Bug Description
I want to delete the lang attribute from an html element that has both
lang and xml:lang attributes. I found I cannot do that consistently.
lxml deletes either lang or xml:lang at random. The results depend on
the order the two attributes are specified in the html source.
--- lxmlbug.py -------
from lxml import etree
html = etree.XML ("<html lang='en' xml:lang='en' />")
del html.attrib['lang']
print etree.tostring (html)
# prints expected: <html xml:lang="en"/>
html = etree.XML ("<html xml:lang='en' lang='en' />")
del html.attrib['lang']
print etree.tostring (html)
# prints unexpected: <html lang="en"/>
print
print "lxml.etree: ", etree.LXML_VERSION
print "libxml used: ", etree.LIBXML_
print "libxml compiled: ", etree.LIBXML_
print "libxslt used: ", etree.LIBXSLT_
print "libxslt compiled: ", etree.LIBXSLT_
-------
$ python lxmlbug.py
<html xml:lang="en"/>
<html lang="en"/>
lxml.etree: (2, 2, 2, 0)
libxml used: (2, 7, 5)
libxml compiled: (2, 7, 3)
libxslt used: (1, 1, 26)
libxslt compiled: (1, 1, 24)
$
Changed in lxml: | |
assignee: | nobody → Stefan Behnel (scoder) |
importance: | Undecided → Medium |
milestone: | none → 2.3 |
status: | New → Confirmed |
This and a couple of similar bugs have been fixed in trunk rev. 68065:
https:/ /codespeak. net/viewvc/ ?view=rev& revision= 68065