mirror of
https://github.com/python/cpython.git
synced 2025-12-08 10:21:13 +00:00
Used original SAX handling form.
This commit is contained in:
parent
99b84bdaad
commit
6c4753f925
3 changed files with 14 additions and 15 deletions
|
|
@ -22,7 +22,7 @@ class PullDOM:
|
||||||
|
|
||||||
def setDocumentLocator( self, locator ): pass
|
def setDocumentLocator( self, locator ): pass
|
||||||
|
|
||||||
def startElement( self, tagName , attrs ):
|
def startElement( self, name, tagName , attrs ):
|
||||||
if not hasattr( self, "curNode" ):
|
if not hasattr( self, "curNode" ):
|
||||||
# FIXME: hack!
|
# FIXME: hack!
|
||||||
self.startDocument( )
|
self.startDocument( )
|
||||||
|
|
@ -42,7 +42,7 @@ class PullDOM:
|
||||||
self.lastEvent=self.lastEvent[1]
|
self.lastEvent=self.lastEvent[1]
|
||||||
#self.events.append( (START_ELEMENT, node) )
|
#self.events.append( (START_ELEMENT, node) )
|
||||||
|
|
||||||
def endElement( self, name ):
|
def endElement( self, name, tagName ):
|
||||||
node = self.curNode
|
node = self.curNode
|
||||||
self.lastEvent[1]=[(END_ELEMENT, node), None ]
|
self.lastEvent[1]=[(END_ELEMENT, node), None ]
|
||||||
self.lastEvent=self.lastEvent[1]
|
self.lastEvent=self.lastEvent[1]
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,8 @@ class ExpatParser( xmlreader.IncrementalParser, xmlreader.Locator ):
|
||||||
self._parser.EndElementHandler = self.end_element_ns
|
self._parser.EndElementHandler = self.end_element_ns
|
||||||
else:
|
else:
|
||||||
self._parser = pyexpat.ParserCreate()
|
self._parser = pyexpat.ParserCreate()
|
||||||
self._parser.StartElementHandler = self._cont_handler.startElement
|
self._parser.StartElementHandler = self.start_element
|
||||||
self._parser.EndElementHandler = self._cont_handler.endElement
|
self._parser.EndElementHandler = self.end_element
|
||||||
|
|
||||||
self._parser.ProcessingInstructionHandler = \
|
self._parser.ProcessingInstructionHandler = \
|
||||||
self._cont_handler.processingInstruction
|
self._cont_handler.processingInstruction
|
||||||
|
|
@ -133,25 +133,22 @@ class ExpatParser( xmlreader.IncrementalParser, xmlreader.Locator ):
|
||||||
def getSystemId(self):
|
def getSystemId(self):
|
||||||
return self._parser.GetBase()
|
return self._parser.GetBase()
|
||||||
|
|
||||||
# internal methods
|
|
||||||
|
|
||||||
# event handlers
|
# event handlers
|
||||||
|
|
||||||
def start_element(self, name, attrs):
|
def start_element(self, name, attrs):
|
||||||
self._cont_handler.startElement(name,
|
self._cont_handler.startElement(name, name,
|
||||||
xmlreader.AttributesImpl(attrs, attrs))
|
xmlreader.AttributesImpl(attrs, attrs))
|
||||||
|
|
||||||
def end_element(self, name):
|
def end_element(self, name):
|
||||||
self._cont_handler.endElement(name)
|
self._cont_handler.endElement( name, name )
|
||||||
|
|
||||||
def start_element_ns(self, name, attrs):
|
def start_element_ns(self, name, attrs):
|
||||||
pair = split(name)
|
pair = split(name)
|
||||||
if len(pair) == 1:
|
if len(pair) == 1:
|
||||||
tup = (None, name, None)
|
tup = (None, name )
|
||||||
else:
|
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))
|
xmlreader.AttributesImpl(attrs, None))
|
||||||
|
|
||||||
def end_element_ns(self, name):
|
def end_element_ns(self, name):
|
||||||
|
|
@ -161,11 +158,13 @@ class ExpatParser( xmlreader.IncrementalParser, xmlreader.Locator ):
|
||||||
else:
|
else:
|
||||||
name = pair+[None] # prefix is not implemented yet!
|
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):
|
def processing_instruction(self, target, data):
|
||||||
self._cont_handler.processingInstruction(target, data)
|
self._cont_handler.processingInstruction(target, data)
|
||||||
|
|
||||||
|
# this is not used
|
||||||
def character_data(self, data):
|
def character_data(self, data):
|
||||||
self._cont_handler.characters(data)
|
self._cont_handler.characters(data)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue