[EMAIL PROTECTED] schrieb:
Hi Andrew,Send XML-SIG mailing list submissions to [EMAIL PROTECTED]
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 [EMAIL PROTECTED]
You can reach the person managing the list at [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> Subject: Re: [XML-SIG] cannot change xmlns:xsi To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Daniel Isenegger <[EMAIL PROTECTED]> 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.
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
_______________________________________________ XML-SIG maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/xml-sig