From a5bf16eb762d904730f8eb51cefd143a648d80ef Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Fri, 7 Mar 2008 09:35:51 +0000 Subject: [PATCH] Use clever implementation to add namespaces declaration git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19749 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5OOo/OOoUtils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/product/ERP5OOo/OOoUtils.py b/product/ERP5OOo/OOoUtils.py index 658545ff47..683dce0b9b 100644 --- a/product/ERP5OOo/OOoUtils.py +++ b/product/ERP5OOo/OOoUtils.py @@ -151,16 +151,19 @@ class OOoBuilder(Implicit): 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) -- 2.30.9