mirror of
https://github.com/python/cpython.git
synced 2025-10-22 14:42:22 +00:00
Updated to new SAX method signatures (*NS, patch 101573).
This commit is contained in:
parent
f43cf31f4a
commit
e84bf751bb
1 changed files with 6 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
import minidom
|
import minidom
|
||||||
import xml.sax
|
import xml.sax
|
||||||
|
|
||||||
#todo: SAX2/namespace handling
|
#todo: namespace handling
|
||||||
|
|
||||||
START_ELEMENT = "START_ELEMENT"
|
START_ELEMENT = "START_ELEMENT"
|
||||||
END_ELEMENT = "END_ELEMENT"
|
END_ELEMENT = "END_ELEMENT"
|
||||||
|
@ -19,13 +19,13 @@ class PullDOM:
|
||||||
|
|
||||||
def setDocumentLocator(self, locator): pass
|
def setDocumentLocator(self, locator): pass
|
||||||
|
|
||||||
def startElement(self, name, tagName, attrs):
|
def startElement(self, name, attrs):
|
||||||
if not hasattr(self, "curNode"):
|
if not hasattr(self, "curNode"):
|
||||||
# FIXME: hack!
|
# FIXME: hack!
|
||||||
self.startDocument()
|
self.startDocument()
|
||||||
|
|
||||||
node = self.document.createElement(tagName) #FIXME namespaces!
|
node = self.document.createElement(name)
|
||||||
for attr in attrs.keys():
|
for (attr, value) in attrs.items():
|
||||||
node.setAttribute(attr, attrs[attr])
|
node.setAttribute(attr, attrs[attr])
|
||||||
|
|
||||||
parent = self.curNode
|
parent = self.curNode
|
||||||
|
@ -34,12 +34,12 @@ class PullDOM:
|
||||||
node.previousSibling = parent.childNodes[-1]
|
node.previousSibling = parent.childNodes[-1]
|
||||||
node.previousSibling.nextSibling = node
|
node.previousSibling.nextSibling = node
|
||||||
self.curNode = node
|
self.curNode = node
|
||||||
# FIXME: do I have to screen namespace attributes
|
|
||||||
self.lastEvent[1] = [(START_ELEMENT, node), None]
|
self.lastEvent[1] = [(START_ELEMENT, node), None]
|
||||||
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, tagName):
|
def endElement(self, name):
|
||||||
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]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue