XML and namespaces

A.M. Kuchling amk at amk.ca
Wed Nov 30 21:08:53 CET 2005

On 30 Nov 2005 07:22:56 -0800, 
	uche.ogbuji at gmail.com <uche.ogbuji at gmail.com> quoted:
>         >>> element = document.createElementNS("DAV:", "href")

This call is incorrect; the signature is createElementNS(namespaceURI,
qualifiedName).  If you call .createElementNS('whatever', 'DAV:href'),
the output is the expected:
	<?xml version="1.0" ?><DAV:href/>

It doesn't look like there's any code in minidom that will
automatically create an 'xmlns:DAV="whatever"' attribute for you.  Is
this automatic creation an expected behaviour?  

(I assume not.  Section 1.3.3 of the DOM Level 3 says "Similarly,
creating a node with a namespace prefix and namespace URI, or changing
the namespace prefix of a node, does not result in any addition,
removal, or modification of any special attributes for declaring the
appropriate XML namespaces."  So the DOM can create XML documents that
aren't well-formed w.r.t. namespaces, I think.)


More information about the Python-list mailing list