[XML-SIG] Re: XML-SIG Digest, Vol 20, Issue 3

Daniel Isenegger disen at geo.unizh.ch
Tue Dec 7 09:48:43 CET 2004


xml-sig-request at python.org schrieb:

>Send XML-SIG mailing list submissions to
>	xml-sig at python.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
>	http://mail.python.org/mailman/listinfo/xml-sig
>or, via email, send a message with subject or body 'help' to
>	xml-sig-request at python.org
>
>You can reach the person managing the list at
>	xml-sig-owner at python.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of XML-SIG digest..."
>
>
>Today's Topics:
>
>   1. Re: cannot change xmlns:xsi (Andrew Clover)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Thu, 02 Dec 2004 16:35:47 +0100
>From: Andrew Clover <and-xml at doxdesk.com>
>Subject: Re: [XML-SIG] cannot change xmlns:xsi
>To: xml-sig at python.org
>Message-ID: <41AF3653.70403 at doxdesk.com>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Daniel Isenegger <disen at geo.unizh.ch> wrote:
>
>  
>
>>node.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")
>>    
>>
>
>setAttribute is a Level 1 method and thus namespace-ignorant. The above 
>should probably work as long as there is already an xmlns:xsi attribute 
>on 'node', but if there isn't it'll create a new one as a Level 1 node, 
>without a namespace. This is just one of the many problems when mixing 
>namespace-aware and namespace-ignorant methods. Really you want:
>
>   XMLNS= 'http://www.w3.org/2000/xmlns/'
>   XSINS= 'http://www.w3.org/2001/XMLSchema-instance'
>   node.setAttributeNS(XMLNS, 'xmlns:xsi', XSINS)
>
>However...
>
>In DOM Level 2, the namespaceURI of an Element or Attr is considered 
>part of its identity, not dynamically recalculated. So, given:
>
>   <a xmlns:q="spam">
>     <q:b/>
>   </a>
>
>you can change the value of the xmlns:q attribute to 'eggs', but the 
>namespaceURI of the q:b element is still 'spam'.
>
>Quite what DOM Level 2 implementations are supposed to do with the 
>problem during output of the document is unspecified, as DOM Level 2 
>says nothing about IO.
>
>But DOM Level 3 LS does. It uses "namespace fixup" to ensure all 
>namespaceURIs survive the output process. You would end up with:
>
>   <a xmlns:q="eggs">
>     <q:b xmlns:q="spam"/>
>   </a>
>
>Therefore correcting the value of the namespace declaration on the root 
>element won't help much; all its descendants would still have the wrong 
>('...w3c...') namespace. You would have to walk over the whole document 
>tree using DOM Level 3's Document.renameNode method to change all their 
>namespaces.
>
>The alternative would be to use a completely namespace-ignorant DOM 
>implementation. For a DOM Level 3 implemenation you can request this by 
>setting the domConfig parameter 'namespaces' to False.
>
>However (again)...
>
>  
>
>>the attribute is temporally set to ...w3... and then reset to ..w3c...
>>    
>>
>
>Having said all that... minidom is not a DOM Level 3 implementation. It 
>doesn't do namespace fixup at all. Its toxml() method just outputs 
>attributes as they are, so it shouldn't be putting the '...w3c...' 
>namespace in anywhere.
>
>So it must be some other tool or part of the program that is having this 
>effect.
>
>  
>
Hi Andrew,
thanks for your help.
 I now at this moment can't see all the consequences of your points, I 
have to study this in greater detail.

All the best     Dani



More information about the XML-SIG mailing list