W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2007

Re: Changing xmlns attribute on the fly.

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Mon, 06 Aug 2007 16:12:23 +0200
To: "Joćo Eiras" <joao.eiras@gmail.com>
Cc: www-dom@w3.org
Message-ID: <9jaeb3t4ro98u3j7sls497kal2fgpg5lam@hive.bjoern.hoehrmann.de>

* Joćo Eiras wrote:
>node.setAttribute('xmlns','http://example.com/');

>I see only two possible outcomes: either an exception is throw or the
>DOM tree has to be rebuilt at runs time.

I am not sure why either would happen. The DOM Core Recommendation quite
clearly says you should not mix namespaces and namespace-unaware methods
and setAttribute is namespace-unaware. What happens should be clear, the
same thing as would happen if you'd used 'foo' instead of 'xmlns'. There
does not need to be an exception, nor would have this any effect on the
namespaces in the document.

Note that especially the latter is also the case if you do e.g.

  node.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:x', '...')

which is quite legal and would not affect the namespaces of <x:x/> ele-
ments, or <y x:x=''/> attributes. The only way to rename elements and
attributes is through the renameNode method. Due to this, it is possible
to create documents that are incorrect with respect to namespaces; there
are fixup algorithms in the specification to correct such errors e.g.
during serialization of the document.

This should all be explained in e.g. section 1.3.3 XML Namespaces of the
Recommendation.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Monday, 6 August 2007 14:12:29 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 10 December 2014 20:11:38 UTC