[XML-SIG] Attribute namespace bug
Uche Ogbuji
uche.ogbuji@fourthought.com
Tue, 30 Oct 2001 14:38:31 -0700
Checked in with your suggestions. Thanks.
--Uche
> On Tue, 30 Oct 2001 14:02:02 -0700, Uche Ogbuji wrote:
> =
> >--- xml/sax/saxutils.py 2001/09/27 21:42:28 1.23
> >+++ xml/sax/saxutils.py 2001/10/30 21:00:45
> >@@ -155,6 +155,8 @@
> > def _outputwrapper(stream,encoding):
> > return stream
> > =
> >+GENERATED_PREFIX =3D "genprefix%s"
> >+
> > class XMLGenerator(handler.ContentHandler):
> =
> =3D=3D=3D> use class attribute, less namespace pollution, =
> use self.GENERATED_PREFIX below!
> =
> class XMLGenerator(handler.ContentHandler):
> GENERATED_PREFIX =3D "genprefix%d"
> =
> Also, do people realize where "genprefix" comes from when =
> it "suddenly pops up"?! Thus, maybe:
> =
> GENERATED_PREFIX =3D "xml.sax.saxutils.prefix%d"
> =
> (it _is_ long, but it should occur in rare cases only anyway)
> =
> > elif self._current_context[name[0]] is None:
> > # default namespace
> >- name =3D name[1]
> >+ #If an attribute has a nsuri but not a prefix, we mus=
t
> >+ #create a prefix and add a nsdecl
> >+ prefix =3D GENERATED_PREFIX % self._generated_prefix_=
ctr
> >+ self._generated_prefix_ctr =3D self._generated_prefix=
_ctr + 1
> >+ name =3D prefix + ':' + name[1]
> >+ self._out.write(' xmlns:%s=3D%s' % (prefix, name[0]))=
> =
> This looks like a bug to me, fix:
> =
> self._out.write(' xmlns:%s=3D%s' % (prefix, quoteattr=
(name[0])))
> =
> >+ self._current_context[name[0]] =3D prefix
> > else:
> > name =3D self._current_context[name[0]] + ":" + name[=
1]
> > self._out.write(' %s=3D%s' % (name, quoteattr(value)))
> =
> =
> Ciao, J=FCrgen
> =
> =
> =
> _______________________________________________
> XML-SIG maillist - XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig
> =