[XML-SIG] gray areas in Python SAX API

Stéphane Bidoul stephane.bidoul@softwareag.com
Sat, 17 Nov 2001 11:01:30 +0100


----- Original Message ----- 
From: "Alexandre Fayolle" <Alexandre.Fayolle@logilab.fr>
To: "Stephane Bidoul" <stephane.bidoul@softwareag.com>
Cc: <xml-sig@python.org>
Sent: Friday, November 16, 2001 6:53 PM
Subject: RE: [XML-SIG] gray areas in Python SAX API

[...]

> What I observed is the following, which made me think that pyexpat and
> xmlproc behaved differently.
> 
> >>> s = "<f a='b'/>"
> >>> from xml.dom.ext.reader.Sax2 import Reader
> >>> from xml.sax import make_parser
> >>> r1 = =
Reader(parser=make_parser("xml.sax.drivers2.drv_pyexpat"))
> >>> r2 = =
Reader(parser=make_parser("xml.sax.drivers2.drv_xmlproc"))
> >>> d1 = r1.fromString(s)
> >>> d2 = r2.fromString(s)
> >>> d1.documentElement.getAttributeNS('','a')
> u'b'
> >>> d1.documentElement.getAttributeNS(None,'a')
> ''
> >>> d2.documentElement.getAttributeNS('','a')
> ''
> >>> d2.documentElement.getAttributeNS(None,'a')
> 'b'
> >>> 
> 
> 
> I agree that this may be caused by one of the parser being in =
namespace
> mode (and using startElementNS) and not the other one (which would be
> using startElement) in which case, the problem would be in the =
handler. 

I think you're right: xml.dom.ext.reader.Sax2 
does not handle start/endPrefixMapping and relies on the fact that
the xmlns attributes are not eliminated by the reader 
(thus that the reader has feature_namespace_prefixes=true 
or feature_namespaces=false).

I was planning to post that as a bug. I can still do it if 
someone else agrees that there is a problem there.

[...]

-Stephane