[XML-SIG] namespace headache

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Tue, 2 May 2000 16:19:12 +0200


reading the XML namespace specification makes my brain
hurt, so I thought I'd ask here before it explodes...

given the following XML snippet, what's the correct namespace
for the "attribute" attribute?

<ns:body xmlns:ns=3D'namespace:'>
    <ns:member attribute=3D'value'>
    </ns:member>
</ns:body>

I'm not smart enough to figure that out from the specification,
my intuition says "no namespace", and so does James Clark's
namespace note (http://www.jclark.com/xml/xmlns.htm) where

<RESERVATION xmlns:HTML=3D"http://www.w3.org/TR/REC-html40">
   <HTML:A HREF=3D'/cgi-bin/ResStatus'>Check Status</HTML:A>
</RESERVATION>

is mapped to:

<RESERVATION>
   <{http://www.w3.org/TR/REC-html40}A HREF=3D'/cgi-bin/ResStatus'
     >Check Status</{http://www.w3.org/TR/REC-html40}A>
</RESERVATION>

(slightly edited -- see the note for the full example).

but 1.5.2's xmllib doesn't agree with this:

import xmllib

class Parser(xmllib.XMLParser):
    def unknown_starttag(self, tag, attr):
        print "S", repr(tag), attr
    def unknown_endtag(self, tag):
        print "E", repr(tag)

p =3D Parser()
p.feed("""
<ns:body xmlns:ns=3D'namespace:'>
    <ns:member attribute=3D'value'>
    </ns:member>
</ns:body>
""")
p.close()

gives the following output:

S 'namespace: body' {}
S 'namespace: member' {'namespace: attribute': 'value'}
E 'namespace: member'
E 'namespace: body'

instead of=20

S 'namespace: body' {}
S 'namespace: member' {'attribute': 'value'}
E 'namespace: member'
E 'namespace: body'

can anyone sort this out for me?

(and no, I really have to be able to use xmllib, to make sure
soaplib.py works under an off-the-shelf Python distribution...)

</F>