diff options
author | Fred Drake <fdrake@acm.org> | 1999-05-07 21:14:28 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-05-07 21:14:28 (GMT) |
commit | 2697694e4a56d9a87b4360b7fa4c7feafce92a94 (patch) | |
tree | d0ee9578e0a50824e042fb62b6421fa0a44b5bcb /Doc | |
parent | f79acbdaa1798eceb5e00ad32bbbfbf191333817 (diff) | |
download | cpython-2697694e4a56d9a87b4360b7fa4c7feafce92a94.zip cpython-2697694e4a56d9a87b4360b7fa4c7feafce92a94.tar.gz cpython-2697694e4a56d9a87b4360b7fa4c7feafce92a94.tar.bz2 |
ExtendedEsisBuilder.push(): Override inherited definition. We don't
want to push nodes into the document, but into a document
fragment, since we're not necesarily working with something
that's well-formed.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tools/sgmlconv/esistools.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Doc/tools/sgmlconv/esistools.py b/Doc/tools/sgmlconv/esistools.py index f44c13c..3e0ffc3 100644 --- a/Doc/tools/sgmlconv/esistools.py +++ b/Doc/tools/sgmlconv/esistools.py @@ -4,6 +4,8 @@ __version__ = '$Revision$' import re import string import sys +import xml.dom.core +import xml.dom.esis_builder _data_rx = re.compile(r"[^\\][^\\]*") @@ -37,14 +39,12 @@ def encode(s): return string.join(map(_charmap.get, s), '') -import xml.dom.esis_builder - - class ExtendedEsisBuilder(xml.dom.esis_builder.EsisBuilder): def __init__(self, *args, **kw): self.__empties = {} self.__is_empty = 0 apply(xml.dom.esis_builder.EsisBuilder.__init__, (self,) + args, kw) + self.fragment = self.document.createDocumentFragment() def feed(self, data): for line in string.split(data, '\n'): @@ -76,5 +76,19 @@ class ExtendedEsisBuilder(xml.dom.esis_builder.EsisBuilder): else: sys.stderr.write('Unknown event: %s\n' % line) + def push(self, node): + "Add node to current node and move to new node." + + nodetype = node.get_nodeType() + if self.current_element: + self.current_element.insertBefore(node, None) + elif nodetype == xml.dom.core.TEXT_NODE: + if string.strip(node.get_nodeValue()): + self.fragment.appendChild(node) + else: + self.fragment.appendChild(node) + if nodetype == xml.dom.core.ELEMENT_NODE: + self.current_element = node + def get_empties(self): return self.__empties.keys() |