diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2000-09-24 18:39:23 (GMT) |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2000-09-24 18:39:23 (GMT) |
commit | 32bf12eb8a5849762721b561f9b48c6e897792e9 (patch) | |
tree | c8470ceda65c34fb1ebc302de8234d902a9ae12b /Lib/xml/sax/expatreader.py | |
parent | e84bf751bb0d18851877518dbb6d382f909f16b4 (diff) | |
download | cpython-32bf12eb8a5849762721b561f9b48c6e897792e9.zip cpython-32bf12eb8a5849762721b561f9b48c6e897792e9.tar.gz cpython-32bf12eb8a5849762721b561f9b48c6e897792e9.tar.bz2 |
Updated to final Attributes interface (patch 101632).
Diffstat (limited to 'Lib/xml/sax/expatreader.py')
-rw-r--r-- | Lib/xml/sax/expatreader.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py index 1120f17..2f1ff1c 100644 --- a/Lib/xml/sax/expatreader.py +++ b/Lib/xml/sax/expatreader.py @@ -20,6 +20,9 @@ from xml.sax._exceptions import * from xml.parsers import expat from xml.sax import xmlreader +AttributesImpl = xmlreader.AttributesImpl +AttributesNSImpl = xmlreader.AttributesNSImpl + # --- ExpatParser class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): @@ -31,7 +34,6 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): self._parser = None self._namespaces = namespaceHandling self._parsing = 0 - self._attrs = xmlreader.AttributesImpl({}, {}) # XMLReader methods @@ -137,7 +139,7 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): # event handlers def start_element(self, name, attrs): - self._cont_handler.startElement(name, self._attrs) + self._cont_handler.startElement(name, AttributesImpl(attrs)) def end_element(self, name): self._cont_handler.endElement(name) @@ -147,12 +149,23 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): if len(pair) == 1: pair = (None, name) - self._cont_handler.startElementNS(pair, None, self._attrs) + newattrs = {} + for (aname, value) in attrs.items(): + apair = aname.split() + if len(apair) == 1: + apair = (None, aname) + else: + apair = tuple(apair) + + newattrs[apair] = value + + self._cont_handler.startElementNS(pair, None, + AttributesNSImpl(newattrs, {})) def end_element_ns(self, name): pair = name.split() if len(pair) == 1: - name = (None, name) + pair = (None, name) self._cont_handler.endElementNS(pair, None) |