[Python-checkins] CVS: python/dist/src/Lib/xml/sax saxutils.py,1.4,1.5
Lars Marius Garshol
python-dev@python.org
Sun, 24 Sep 2000 03:53:35 -0700
Update of /cvsroot/python/python/dist/src/Lib/xml/sax
In directory slayer.i.sourceforge.net:/tmp/cvs-serv7080
Modified Files:
saxutils.py
Log Message:
Bug fix to namespace handling in XMLGenerator (now adds declarations).
Bug fixes to XMLFilterBase (wrong ignorableWhitespace signature and
did not inherit set*Handler methods from XMLReader.)
Index: saxutils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/saxutils.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** saxutils.py 2000/09/21 08:25:28 1.4
--- saxutils.py 2000/09/24 10:53:31 1.5
***************
*** 5,10 ****
import handler
-
def escape(data, entities={}):
"""Escape &, <, and > in a string of data.
--- 5,10 ----
import handler
+ import xmlreader
def escape(data, entities={}):
"""Escape &, <, and > in a string of data.
***************
*** 32,35 ****
--- 32,36 ----
self._ns_contexts = [{}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
+ self._undeclared_ns_maps = []
self._encoding = encoding
***************
*** 43,49 ****
self._ns_contexts.append(self._current_context.copy())
self._current_context[uri] = prefix
def endPrefixMapping(self, prefix):
! del self._current_context[-1]
def startElement(self, name, attrs):
--- 44,52 ----
self._ns_contexts.append(self._current_context.copy())
self._current_context[uri] = prefix
+ self._undeclared_ns_maps.append((prefix, uri))
def endPrefixMapping(self, prefix):
! self._current_context = self._ns_contexts[-1]
! del self._ns_contexts[-1]
def startElement(self, name, attrs):
***************
*** 59,62 ****
--- 62,70 ----
name = self._current_context[name[0]] + ":" + name[1]
self._out.write('<' + name)
+
+ for pair in self._undeclared_ns_maps:
+ self._out.write(' xmlns:%s="%s"' % pair)
+ self._undeclared_ns_maps = []
+
for (name, value) in attrs.items():
name = self._current_context[name[0]] + ":" + name[1]
***************
*** 78,82 ****
! class XMLFilterBase:
"""This class is designed to sit between an XMLReader and the
client application's event handlers. By default, it does nothing
--- 86,90 ----
! class XMLFilterBase(xmlreader.XMLReader):
"""This class is designed to sit between an XMLReader and the
client application's event handlers. By default, it does nothing
***************
*** 129,134 ****
self._cont_handler.characters(content)
! def ignorableWhitespace(self, chars, start, end):
! self._cont_handler.ignorableWhitespace(chars, start, end)
def processingInstruction(self, target, data):
--- 137,142 ----
self._cont_handler.characters(content)
! def ignorableWhitespace(self, chars):
! self._cont_handler.ignorableWhitespace(chars)
def processingInstruction(self, target, data):