From: sgunderson@bigfoot.com <> Date: Wed, 6 Sep 2006 16:30:00 +0000 (+0200) Subject: Fix some possible attribute issues with the Python code, and make it clean X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a1cfd19c4c66e6c78740427fc8bb905037b409d9;p=xml-template Fix some possible attribute issues with the Python code, and make it clean away the xmlns stuff. --- diff --git a/python/xmltemplate.py b/python/xmltemplate.py index 6b9c50b..1953149 100644 --- a/python/xmltemplate.py +++ b/python/xmltemplate.py @@ -32,13 +32,21 @@ def process(node, obj, clean = True): 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