[Python-modules-commits] [python-odf] 40/118: Fixed the problem with the 'xml' namespace

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 21:27:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to reference refs/remotes/upstream/master
in repository python-odf.

commit a481ab993323b9c283f7d4df00b36355753f387e
Author: Søren Roug <soren.roug at eea.europa.eu>
Date:   Wed Jan 21 21:48:12 2009 +0000

    Fixed the problem with the 'xml' namespace
---
 odf/namespaces.py         |  2 +-
 odf/userfield.py          | 13 +++++++++++++
 odf2mht/odf2mht.1         | 13 ++++++++-----
 odfimgimport/odfimgimport | 13 +++++++++++++
 4 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/odf/namespaces.py b/odf/namespaces.py
index d8ce709..5940535 100644
--- a/odf/namespaces.py
+++ b/odf/namespaces.py
@@ -49,7 +49,7 @@ TABLENS        = u"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
 TEXTNS         = u"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
 XFORMSNS       = u"http://www.w3.org/2002/xforms"
 XLINKNS        = u"http://www.w3.org/1999/xlink"
-XMLNS          = "http://www.w3.org/XML/1998/namespace"
+XMLNS          = u"http://www.w3.org/XML/1998/namespace"
 
 
 nsdict = {
diff --git a/odf/userfield.py b/odf/userfield.py
index 5014358..3d97724 100644
--- a/odf/userfield.py
+++ b/odf/userfield.py
@@ -231,6 +231,19 @@ class ODFContentParser(xml.sax.saxutils.XMLGenerator):
         self._callback_func = callback_func
         xml.sax.saxutils.XMLGenerator.__init__(self, out, encoding)
 
+    def _qname(self, name):
+        """Builds a qualified name from a (ns_url, localname) pair"""
+        if name[0]:
+            if name[0] == u'http://www.w3.org/XML/1998/namespace':
+                return u'xml' + ":" + name[1]
+            # The name is in a non-empty namespace
+            prefix = self._current_context[name[0]]
+            if prefix:
+                # If it is not the default namespace, prepend the prefix
+                return prefix + ":" + name[1]
+        # Return the unqualified name
+        return name[1]
+
     def startElementNS(self, name, qname, attrs):
         if name == (TEXTNS, u'user-field-decl'):
             field_name = attrs.get((TEXTNS, u'name'))
diff --git a/odf2mht/odf2mht.1 b/odf2mht/odf2mht.1
index 50feace..7b4f773 100644
--- a/odf2mht/odf2mht.1
+++ b/odf2mht/odf2mht.1
@@ -1,12 +1,12 @@
 .\"     Title: odf2mht
 .\"    Author: S\(/oren Roug
 .\" Generator: DocBook XSL Stylesheets v1.74.0 <http://docbook.sf.net/>
-.\"      Date: 01/04/2009
+.\"      Date: 01/21/2009
 .\"    Manual: User commands
 .\"    Source: odfpy
 .\"  Language: English
 .\"
-.TH "ODF2MHT" "1" "01/04/2009" "odfpy" "User commands"
+.TH "ODF2MHT" "1" "01/21/2009" "odfpy" "User commands"
 .\" -----------------------------------------------------------------
 .\" * (re)Define some macros
 .\" -----------------------------------------------------------------
@@ -175,8 +175,8 @@ odf2mht \- Convert ODF to HTML archive
 .fam
 .SH "Description"
 .PP
-\fBodf2mht\fR
-is a program that will create a MIME\-encapsulated web archive (\&.mht) format that can be read by Internet Explorer and many email programs such as MS\-Outlook\&. It will write the web archive to stdout\&. IE6 seems to have problems with large MHT files\&.
+\fBOdf2mht\fR
+is a program that will create a MIME\-encapsulated web archive (\&.mht) format where images are preserved\&. The file can be read by Internet Explorer, MS\-Word and many email programs such as MS\-Outlook\&. It will write the web archive to stdout\&.
 .PP
 "Path" is assumed to be an OpenDocument file of text, spreadsheet or presentation type\&.
 .SH "References"
@@ -209,7 +209,7 @@ http://www\&.faqs\&.org/rfcs/rfc2557\&.html
 .BB lightgray adjust-for-leading-newline
 .sp -1
 
-odf2mht odf\-file
+odf2mht example\&.odt >example\&.mht
 .EB lightgray adjust-for-leading-newline
 .if t \{\
 .sp 1
@@ -220,6 +220,9 @@ odf2mht odf\-file
 .if n \{\
 .RE
 .\}
+.SH "Bugs"
+.PP
+IE6 seems to have problems with large MHT files\&.
 .SH "See Also"
 .PP
 
diff --git a/odfimgimport/odfimgimport b/odfimgimport/odfimgimport
index f05f684..edc9b12 100755
--- a/odfimgimport/odfimgimport
+++ b/odfimgimport/odfimgimport
@@ -158,6 +158,19 @@ class odfcontentparser(base):
         self.seenfields = {}
         base.__init__(self, self.output, OUTENCODING)
 
+    def _qname(self, name):
+        """Builds a qualified name from a (ns_url, localname) pair"""
+        if name[0]:
+            if name[0] == u'http://www.w3.org/XML/1998/namespace':
+                return u'xml' + ":" + name[1]
+            # The name is in a non-empty namespace
+            prefix = self._current_context[name[0]]
+            if prefix:
+                # If it is not the default namespace, prepend the prefix
+                return prefix + ":" + name[1]
+        # Return the unqualified name
+        return name[1]
+
     def startElementNS(self, name, qname, attrs):
         if name == (DRAWNS,u'image'):
             href = attrs.get((XLINKNS,u'href'))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-odf.git



More information about the Python-modules-commits mailing list