From 6c4753f925467e5908a43d2fec6d15b76e878d42 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Tue, 4 Jul 2000 03:39:33 +0000 Subject: [PATCH] Used original SAX handling form. --- Lib/xml/dom/minidom.py | 4 ++-- Lib/xml/dom/pulldom.py | 4 ++-- Lib/xml/sax/expatreader.py | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 337ff0375b4..981e5116f3b 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -41,7 +41,7 @@ class Node: Node.allnodes[index]=repr( self.__dict__ ) if Node.debug==None: Node.debug=StringIO() - #open( "debug4.out", "w" ) + #open( "debug4.out", "w" ) Node.debug.write( "create %s\n"%index ) def __getattr__( self, key ): @@ -230,7 +230,7 @@ dictionary""" else: assert isinstance( value, Attr ) or type( value )==types.StringType node=value - old=self._attrs.get( attname, None) + old=self._attrs.get( attname, None) if old: old.unlink() self._attrs[node.name]=node diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py index 0c047f67874..1f7c6997514 100644 --- a/Lib/xml/dom/pulldom.py +++ b/Lib/xml/dom/pulldom.py @@ -22,7 +22,7 @@ class PullDOM: def setDocumentLocator( self, locator ): pass - def startElement( self, tagName , attrs ): + def startElement( self, name, tagName , attrs ): if not hasattr( self, "curNode" ): # FIXME: hack! self.startDocument( ) @@ -42,7 +42,7 @@ class PullDOM: self.lastEvent=self.lastEvent[1] #self.events.append( (START_ELEMENT, node) ) - def endElement( self, name ): + def endElement( self, name, tagName ): node = self.curNode self.lastEvent[1]=[(END_ELEMENT, node), None ] self.lastEvent=self.lastEvent[1] diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py index b6816a43a75..f7517b18566 100644 --- a/Lib/xml/sax/expatreader.py +++ b/Lib/xml/sax/expatreader.py @@ -101,8 +101,8 @@ class ExpatParser( xmlreader.IncrementalParser, xmlreader.Locator ): self._parser.EndElementHandler = self.end_element_ns else: self._parser = pyexpat.ParserCreate() - self._parser.StartElementHandler = self._cont_handler.startElement - self._parser.EndElementHandler = self._cont_handler.endElement + self._parser.StartElementHandler = self.start_element + self._parser.EndElementHandler = self.end_element self._parser.ProcessingInstructionHandler = \ self._cont_handler.processingInstruction @@ -133,25 +133,22 @@ class ExpatParser( xmlreader.IncrementalParser, xmlreader.Locator ): def getSystemId(self): return self._parser.GetBase() - # internal methods - # event handlers - def start_element(self, name, attrs): - self._cont_handler.startElement(name, + self._cont_handler.startElement(name, name, xmlreader.AttributesImpl(attrs, attrs)) def end_element(self, name): - self._cont_handler.endElement(name) + self._cont_handler.endElement( name, name ) def start_element_ns(self, name, attrs): pair = split(name) if len(pair) == 1: - tup = (None, name, None) + tup = (None, name ) else: - tup = pair+[None] # prefix is not implemented yet! + tup = pair - self._cont_handler.startElement(tup, + self._cont_handler.startElement(tup, None, xmlreader.AttributesImpl(attrs, None)) def end_element_ns(self, name): @@ -161,11 +158,13 @@ class ExpatParser( xmlreader.IncrementalParser, xmlreader.Locator ): else: name = pair+[None] # prefix is not implemented yet! - self._cont_handler.endElement(name) + self._cont_handler.endElement(name, None) + # this is not used def processing_instruction(self, target, data): self._cont_handler.processingInstruction(target, data) + # this is not used def character_data(self, data): self._cont_handler.characters(data)