[4suite] Namespace bug in 4DOM (Pretty)Print ?

Alexandre Fayolle alf at logilab.com
Tue Sep 19 11:01:28 MDT 2000


On Tue, 19 Sep 2000, Uche Ogbuji wrote:

> > >>> from xml.dom.ext.reader import Sax2
> > >>> from xml.dom.ext import PrettyPrint
> > >>> d=Sax2.FromXml('<doc/>')
> > >>> e = d.createElement('elt')
> > >>> d.documentElement.appendChild(e)
> > >>> e.setAttributeNS('http://logilab','att','value1')
> 
> Oops.  We should throw an exception here.  This is a NAMESPACE_ERR
> according to DOM L2.  You won't be able to do this in the coming
> release.

Arg, I had missread the DOM2 spec. I had thought that it would cause
something like: <elt http://logilab:att='value1'> to be inserted in the
document (since there was no exception thrown, I had thought the
createAttributeNS statement was correct without double ckecking in
DOM2). And yes, I now know this is not valid XML, but I thought it was
because I had read it once in an outdated book. I've just reread XMLBase
and I now know my fault. Thanks for pointing it out.


> 
> > >>> PrettyPrint(d)
> > <doc>
> >   <elt xmlns = 'http://logilab' att='value1'/>
> > 
> > this causes a default namespace to be used for <elt> and no namespace for
> > 'att'. Notice that no end tag for doc was printed.
> 
> I think the lack of end tag might be an illusion.  Because the printer
<snip>
> the pending release code and could not reproduce the lack of end tag.

Surely was : I could not reproduce it either. Sorry.

> BTW, should we have the printers append a carriage return to the output
> to avoid such confusion?  I think maybe it's a good idea...

I agree. 

> Hmm.  Considering that you won't be able to do this for long, we should
> discuss why you need to use mal-formed namespaces?

As I said earlier, it was an error on our side. We obviously don't want to
use malformed namespaces ;o) and had just misread the spec. It's good
thing we asked though, since it pointed out a bug. :o/

-- 
Alexandre Fayolle
http://www.logilab.com - "Mais o est donc Ornicar ?" - 
LOGILAB, Paris (France).




More information about the 4suite mailing list