Skip to content

Commit e9672ab

Browse files
committed
Cleanup TODOs
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40499
1 parent 611e8d6 commit e9672ab

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/liberalxmlparser.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
* http://wiki.whatwg.org/wiki/HtmlVsXhtml
1212
1313
@@TODO:
14-
* Produce SAX events based on the produced DOM. This is intended not to
15-
support streaming, but rather to support application level compatibility.
16-
* Optional namespace support
17-
* Investigate the use of <![CDATA[]]> when tokenizer.contentModelFlag
18-
indicates CDATA processsing to ensure dual HTML/XHTML compatibility.
1914
* Selectively lowercase only XHTML, but not foreign markup
2015
"""
2116

src/treebuilders/dom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def dom2sax(node, handler, nsmap={'xml':XML_NAMESPACE}):
139139
if node.nodeType == Node.ELEMENT_NODE:
140140
if not nsmap:
141141
handler.startElement(node.nodeName, node.attributes)
142-
for child in node.childNodes: dom2sax(child, handler)
142+
for child in node.childNodes: dom2sax(child, handler, nsmap)
143143
handler.endElement(node.nodeName)
144144
else:
145145
attributes = dict(node.attributes.itemsNS())

tests/test_sax.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ class SAXTest(unittest.TestCase):
3030
def DOMParse(self, input):
3131
return XMLParser(tree=dom.TreeBuilder).parse(input)
3232

33+
def setNS(self, saxparser):
34+
import xml.dom
35+
saxparser.setFeature(xml.sax.handler.feature_namespaces, 1)
36+
return {'xml':xml.dom.XML_NAMESPACE}
37+
3338
def saxdiff(self, input):
3439
domhandler = SAXLogger()
35-
dom.dom2sax(self.DOMParse(input), domhandler)
3640

3741
saxhandler = SAXLogger()
3842
saxparser = xml.sax.make_parser(PREFERRED_XML_PARSERS)
39-
saxparser.setFeature(xml.sax.handler.feature_namespaces, 1)
43+
44+
dom.dom2sax(self.DOMParse(input), domhandler, self.setNS(saxparser))
45+
4046
saxparser.setContentHandler(saxhandler)
4147
source = xml.sax.xmlreader.InputSource()
4248
source.setByteStream(StringIO.StringIO(input))
@@ -85,6 +91,11 @@ def test_ns(self):
8591
</svg>
8692
</body></html>""")
8793

94+
# Repeat tests without namespace support
95+
class nonamespaceTest(SAXTest):
96+
def setNS(self, saxparser):
97+
return None
98+
8899
# Redundantly rerun all tests using the "real" minidom parser, just to be
89100
# sure that the output is consistent
90101
class minidomTest(SAXTest):

0 commit comments

Comments
 (0)