]> git.sesse.net Git - xml-template/blobdiff - python/xmltemplate.py
Fix a potential bug in the C++0x cleaning.
[xml-template] / python / xmltemplate.py
index 94135251089c1df5e7ae3bf966be17b0e36d1a45..b24d7642ccda30a0173ccd345fc413a313e19dbd 100644 (file)
@@ -8,7 +8,7 @@ def process_file(filename, obj, clean = True):
        return doc
 
 def process(node, obj, clean = True):
-       if isinstance(obj, str):                        # overwrite
+       if isinstance(obj, basestring):                 # overwrite
                while not node.firstChild is None:
                        node.removeChild(node.firstChild)
                doc = _get_document_element(node)
@@ -35,8 +35,8 @@ def process(node, obj, clean = True):
                                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":
+                                               attr = attrs.item(i)
+                                               if attr.namespaceURI == "http://template.sesse.net/" and attr.localName == "id":
                                                        id = attr.value
                                                        if clean:
                                                                attrs_to_remove.append(attr.name)