[XML-SIG] Bogus SAX test case

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Tue, 26 Sep 2000 22:34:41 +0200

test_sax.py has the test case test_xmlgen_ns, which reads

ns_uri = "http://www.python.org/xml-ns/saxtest/"

    gen.startPrefixMapping("ns1", ns_uri)
    gen.startElementNS((ns_uri, "doc"), "ns:doc", {})
    gen.endElementNS((ns_uri, "doc"), "ns:doc")

Translating that to XML, it should look like

<?xml version="1.0" encoding="iso-8859-1"?>
<ns:doc xmlns:ns1="http://www.python.org/xml-ns/saxtest/"><ns:doc/>

(or, alternatively, the element could just be empty). Is that the XML
that would produce above sequence of SAX events?

It seems to me that this XML is ill-formed, the namespace prefix ns is
not defined here. Is that analysis correct? Furthermore, the test
checks whether the generator produces

<?xml version="1.0" encoding="iso-8859-1"?>
<ns1:doc xmlns:ns1="http://www.python.org/xml-ns/saxtest/"></ns1:doc>

It appears that the expected output is bogus; I'd rather expect to get
the original document back.

I noticed this because in PyXML, XMLGenerator *would* produce ns:doc
on output, so the test case broke. I have now changed PyXML to follow
Python 2.0b2 here.

My proposal would be to correct the test case to pass "ns1:doc" as the
qname, and to correct the generator to output the qname if that was
provided by the reader.