id = None
attrs = child.attributes
+ attrs_to_remove = []
if not attrs is None:
for i in range(attrs.length):
attr = attrs.item(0)
if attr.namespaceURI == "http://template.sesse.net/" or attr.name == "id":
id = attr.value
if clean:
- child.removeAttribute(attr.name)
+ attrs_to_remove.append(attr.name)
+ if attr.name.startswith("xmlns:") and attr.value == "http://template.sesse.net/" and clean:
+ attrs_to_remove.append(attr.name)
+
+ for a in attrs_to_remove:
+ if child.hasAttribute(a):
+ child.removeAttribute(a)
+
# check all substitutions to see if we found anything
# appropriate