[XML-SIG] help - attributes namespace - is this a bug in PyXML
Uche Ogbuji
uche.ogbuji at fourthought.com
Thu Aug 19 21:38:16 CEST 2004
On Mon, 2004-08-16 at 09:45, Ajay wrote:
> hi!
>
> for the XML
> <appel:RULESET xmlns:appel="http://www.w3.org/2001/02/appelv1"
> xmlns:p3p="http://www.w3.org/2000/12/p3pv1">
> <appel:RULE prompt="no">
> <p3p:POLICY>
> <p3p:ACCESS appel:connective="non-and">
> <p3p:all/>
> </p3p:ACCESS>
> </p3p:POLICY>
> </appel:RULE>
>
> if i getupto the "ACCESS" element and print its attribute name and value
> using
> if attribs != None and len(attribs) > 0:
> index = 0
> while index < attribs.length:
> print "attribute ", index, ": ", attribs.item(index).nodeName, " has
> value: ", attribs.item(index).nodeValue
> index += 1
>
> it prints ACCESS having the attribute "appel:connective" with the value
> "non-and"
> the statement attribs.getNamedItem("appel:connective") however returns
> None.
> now i think its substituting the namespace for appel but then how would you
> access the attribute, just 'connective' doesn't work, 'appel:connective'
> doesn't either and http://www.w3.org/2001/02/appelv1:connective doesn't
> work either.
If you're accessing nodes in namespaces, you have to use the
namespace-aware APIs. These have "NS" at the ends of their names. Then
forget the QName. You need
getNamedItemNS("http://www.w3.org/2001/02/appelv1", "connective")
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
Decomposition, Process, Recomposition - http://www.xml.com/pub/a/2004/07/28/py-xml.html
Perspective on XML: Steady steps spell success with Google - http://www.adtmag.com/article.asp?id=9663
Managing XML libraries - http://www.adtmag.com/article.asp?id=9160
Commentary on "Objects. Encapsulation. XML?" - http://www.adtmag.com/article.asp?id=9090
Harold's Effective XML - http://www.ibm.com/developerworks/xml/library/x-think25.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/
More information about the XML-SIG
mailing list