]> git.sesse.net Git - xml-template/commitdiff
Fix some possible attribute issues with the Python code, and make it clean
authorsgunderson@bigfoot.com <>
Wed, 6 Sep 2006 16:30:00 +0000 (18:30 +0200)
committersgunderson@bigfoot.com <>
Wed, 6 Sep 2006 16:30:00 +0000 (18:30 +0200)
away the xmlns stuff.

python/xmltemplate.py

index 6b9c50b65d2f035e45617b07f874c24d400eccf1..19531496f7d08af8d76df86c515c63cb1dcfe337 100644 (file)
@@ -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