Missing option to change namespace mappings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
This is essentially a summary of a thread on the mailinglist: http://
For some XML processing tools I need to be able to change the namespace mapping, specifically to insert a new entry into the namespace map. My test code looked like this:
NS="http://
tree=lxml.
root=tree.getroot()
count=1
if "i18n" not in root.nsmap:
root.
for el in root.iter():
if "{%s}translate" % NS in el.attrib:
continue
if hasText(el):
count+=1
print lxml.etree.
This did not work since root.nsmap ignores any changes you make in it. An alternative implementation suggested by Simon Wiles created a new root element with the right nsmap and moved all children over, but approach looses data (specifcally the docinfo).
The missing lxml feature to make this possible is a way to change the namespace mapping.
Changed in lxml: | |
importance: | Undecided → Wishlist |
Changed in lxml: | |
status: | New → Confirmed |
This is critical to convert XML-like versions as GPX 1.0 to 1.1.