[XML-SIG] [SOLVED] soapy hacking -- getAttributeNS

Mark Bucciarelli mark@easymailings.com
Sun, 2 Mar 2003 19:55:59 -0500


On Saturday 01 March 2003 6:42 pm, Uche Ogbuji wrote:

[...]

> Your problem, as I mentioned, was that you should have been using
> xml.dom.EMPTY_NAMESPACE, which is None, not ''.

Yes, thank you for your tip.

> > Another interesting thing I found is if an attribute does have a prefix,
> > then the xmlns declaration must be in a parent tag--it cannot be in the
> > same tag as the attribute.
>
> Hmm?  Not true at all.

[...]

> >>> from xml.dom.ext.reader import Sax2
> >>> reader = Sax2.Reader()
> >>> doc = reader.fromString("<root><test xmlns:mb='http://123'
> >>> mb:name='abc' />
>
> </root>")
>
> >>> test_node = doc.documentElement.firstChild
> >>> test_node.getAttributeNS(u'http://123', u'name')
>
> u'abc'

Shouldn't it work with minidom?

>>> import xml.dom.minidom
>>> doc = xml.dom.minidom.parseString("<section xlmns:mb='http://123' 
mb:name='abc'/>")
>>> doc.childNodes[0].getAttributeNS(u'http://123', u'name')
''

> BTW, using 4Suite's Domlette, which is *much* faster than 4DOM you would 
use:
> >>> from Ft.Xml.Domlette import NonvalidatingReader
> >>> doc = NonvalidatingReader.parseString("<root><test
> >>> xmlns:mb='http://123'
>
> mb:name='abc' /></root>","file:bogus.xml")
>
> >>> test_node = doc.documentElement.firstChild
> >>> test_node.attributes[(u'http://123', u'name')].value
>
> u'abc'

I was developing using Python 2.1 and 4Suite and the wsdllib.py library (which 
requires Ft.Lib.pDomlette).  When I downloaded the 2.2 4Suite Windows 
installer, there was no pDomlette.py.  

I suppose I could have used the 0.11 version with Python 2.2 on Windows, but 
it wasn't clear and (at the time) it seemed like a good idea to create a 
small file that reads wsdl and makes soap calls and works with native python 
libraries.

> May I suggest my Python/XML articles?  They cover some of the issues you've
> run into:
>
> http://www.xml.com/pub/au/84

I've seen many of these before, thank you for all your work!

> There is also a lot of relevant stuff on my Akara site:
>
> http://uche.ogbuji.net/tech/akara/nodes/2003-01-01/pyxml-akara

Hmmm, "Waiting for a reply" ...

Mark