[XML-SIG] gray areas in Python SAX API

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Fri, 16 Nov 2001 18:53:53 +0100 (CET)


On Fri, 16 Nov 2001, Stephane Bidoul wrote:

> > way of reporting no-namespace (None or '')
> >  * decide which one to use. Already done, I think, but I 
> > cannot remember
> > what the decision was
> >  * PyExpat uses '', xmlproc uses None. Using None has a 
> > strong impact on
> > code using DOM.
> 
> In my experience, Sax2 drivers report None.
> (xml.sax.drivers2.drv_pyexpat and drv_xmlproc do, at least).
> But this is not always interpreted correctly everywhere
> (for instance by XMLGenerator: see bug #469463).

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'll investigate this next monday (after reading the tons of mail people
will be sending on the list during the week end)

Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).