Removed namespaces declaration in subtree elements xml description when copy/paste
authorLaurent Bessard
Mon, 02 Sep 2013 09:41:15 +0200
changeset 1300 8e1ee07bdff8
parent 1299 9ffc49bfdf9d
child 1301 fcca121a000f
Removed namespaces declaration in subtree elements xml description when copy/paste
xmlclass/xmlclass.py
--- a/xmlclass/xmlclass.py	Fri Aug 30 18:10:30 2013 +0200
+++ b/xmlclass/xmlclass.py	Mon Sep 02 09:41:15 2013 +0200
@@ -2009,6 +2009,8 @@
 This function generate a xml parser from a class factory
 """
 
+NAMESPACE_PATTERN = re.compile("xmlns(?:\:[^\=]*)?=\"[^\"]*\" ")
+
 class DefaultElementClass(etree.ElementBase):
     
     def init(self):
@@ -2018,7 +2020,7 @@
         return etree.QName(self.tag).localname
         
     def tostring(self):
-        return etree.tostring(self, pretty_print=True)
+        return NAMESPACE_PATTERN.sub("", etree.tostring(self, pretty_print=True))
 
 class XMLElementClassLookUp(etree.PythonElementClassLookup):