[Checkins] SVN: Sandbox/malthe/chameleon.core/ Do not apply namespace attribute 'xmlns' to root element if not set.

Malthe Borch mborch at gmail.com
Mon Nov 24 09:31:35 EST 2008


Log message for revision 93306:
  Do not apply namespace attribute 'xmlns' to root element if not set.

Changed:
  U   Sandbox/malthe/chameleon.core/CHANGES.txt
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py

-=-
Modified: Sandbox/malthe/chameleon.core/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-24 13:17:06 UTC (rev 93305)
+++ Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-24 14:31:34 UTC (rev 93306)
@@ -4,6 +4,9 @@
 HEAD
 ~~~~
 
+- Do not apply namespace attribute 'xmlns' to root element if not
+  set. [malthe]
+
 - Fixed tuple unpacking in repeat loops. [malthe]
 
 - Use a custom simple BufferIO class for the lxml.etree parser instead of

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py	2008-11-24 13:17:06 UTC (rev 93305)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py	2008-11-24 14:31:34 UTC (rev 93306)
@@ -647,9 +647,11 @@
                 del element.attrib[utils.metal_attr('define-macro')]
                 
         if macro is None or 'include_ns_attribute' in parameters:
-            # add namespace attribute to 
-            namespace = self.root.tag.split('}')[0][1:]
-            self.root.attrib['xmlns'] = namespace
+            # is root element carries a namespace, add 'xmlns'
+            # attribute to it
+            if '}' in self.root.tag:
+                namespace = self.root.tag.split('}')[0][1:]
+                self.root.attrib['xmlns'] = namespace
         
         if global_scope:
             wrapper = generation.template_wrapper



More information about the Checkins mailing list