[Erp5-report] r19749 - /erp5/trunk/products/ERP5OOo/OOoUtils.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 7 10:35:53 CET 2008


Author: nicolas
Date: Fri Mar  7 10:35:51 2008
New Revision: 19749

URL: http://svn.erp5.org?rev=19749&view=rev
Log:
Use clever implementation to add namespaces declaration

Modified:
    erp5/trunk/products/ERP5OOo/OOoUtils.py

Modified: erp5/trunk/products/ERP5OOo/OOoUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoUtils.py?rev=19749&r1=19748&r2=19749&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoUtils.py (original)
+++ erp5/trunk/products/ERP5OOo/OOoUtils.py Fri Mar  7 10:35:51 2008
@@ -151,16 +151,19 @@
       stylesheet = libxslt.parseStylesheetDoc(stylesheet_doc)
       content_doc = libxml2.parseDoc(content_xml)
       result_doc = stylesheet.applyStylesheet(content_doc, None)
+      #Declare zope namespaces
+      root = result_doc.getRootElement()
+      tal = root.newNs('http://xml.zope.org/namespaces/tal', 'tal')
+      i18n = root.newNs('http://xml.zope.org/namespaces/i18n', 'i18n')
+      metal = root.newNs('http://xml.zope.org/namespaces/metal', 'metal')
+      root.setNs(tal)
+      root.setNs(i18n)
+      root.setNs(metal)
+      root.setNsProp(tal, 'attributes', 'dummy python:request.RESPONSE.setHeader(\'Content-Type\', \'text/html;; charset=utf-8\')')
       buff = libxml2.createOutputBuffer(output, 'utf-8')
       result_doc.saveFormatFileTo(buff, 'utf-8', 1)
       stylesheet_doc.freeDoc(); content_doc.freeDoc(); result_doc.freeDoc()
-      return output.getvalue().replace(
-        'office:version="1.0">',
-        """ xmlns:tal="http://xml.zope.org/namespaces/tal"
-            xmlns:i18n="http://xml.zope.org/namespaces/i18n"
-            xmlns:metal="http://xml.zope.org/namespaces/metal"
-            tal:attributes="dummy python:request.RESPONSE.setHeader('Content-Type', 'text/html;; charset=utf-8')"
-          office:version="1.0">""")
+      return output.getvalue()
     except ImportError:
       reader = PyExpat.Reader()
       document = reader.fromString(content_xml)




More information about the Erp5-report mailing list