[XML-SIG] Conditions for using XLink

Fredrik Lundh fredrik@pythonware.com
Thu, 4 Apr 2002 22:26:32 +0200


dinu wrote:

> And after looking into the test suite I'm able to get it, but *only* 
> in this way:
> 
>   xlink_href = node.getAttributeNS('http://www.w3.org/1999/xlink', 'href')
> 
> but not as I had liked, e.g. like this:
> 
>   xlink_href = node.getAttributeNS('xlink', 'href')
> 
> So, I wonder if I really need to give the full URI, because that would 
> mean I need to store this at the beginning for the root element. I'm
> feeling like I must be doing or getting something wrong about it...

you're confused.  the XLink specification defines the URI, not
the prefix.  whoever creates your XML file can use whatever
prefix they like, as long as they map it to the right URI (see
section 4 of the XLink specification for details).

in your code, do

    NS_XLINK = 'http://www.w3.org/1999/xlink'

    xlink_href = node.getAttributeNS(NS_XLINK, 'href')

and forget about the prefix.

::

you might also wish to read up on XML namespaces.  this article
by james clark might help:

    http://www.jclark.com/xml/xmlns.htm

hope this helps!

</F>