]> git.sesse.net Git - xml-template/commitdiff
Fix cleaning in the Python version. clone test passes!
authorsgunderson@bigfoot.com <>
Wed, 6 Sep 2006 15:56:37 +0000 (17:56 +0200)
committersgunderson@bigfoot.com <>
Wed, 6 Sep 2006 15:56:37 +0000 (17:56 +0200)
python/xmltemplate.py

index 8f2b9222eab4340ee0866138d3df8ce83f42133c..b134ae9ffba21c3c114f5f93cb53d80907043778 100644 (file)
@@ -83,7 +83,18 @@ def alternate(tag, array, *elems):
        return array
 
 def _clean(node):
-       pass
+       if node.nodeType == xml.dom.Node.ELEMENT_NODE and node.namespaceURI == "http://template.sesse.net/":
+               # as this is a dummy node, we want to remove it and move everything further up
+               # after we've done any required replacements
+               doc = _get_document_element(node)
+               parent = node.parentNode
+
+               while not node.firstChild is None:
+                       child = node.firstChild
+                       node.removeChild(child)
+                       parent.insertBefore(child, node)
+
+               parent.removeChild(node)
 
 # ugh
 def _get_document_element(node):