This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xml.dom.minidom does not support default namespaces
Type: behavior Stage: resolved
Components: XML Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, crass, ezio.melotti, jkloth
Priority: normal Keywords:

Created on 2011-10-04 20:11 by crass, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py crass, 2011-10-04 20:11 Illustrative test case
Messages (3)
msg144924 - (view) Author: Glenn Washburn (crass) Date: 2011-10-04 20:11
When using getAttributeNS, attributes with no namespace should be considered as having the default namespace for that scope.  See examples in http://www.w3.org/TR/REC-xml-names/#defaulting.  Python's xml.dom.minidom will always set the namespace to None for attributes that have no namespace prefix.

I've attached a test program to illustrate this issue in action.  The output I get is:
[((None, u'attr'), u'value1')]
[(('http://www.w3.org/2000/xmlns/', 'xmlns'), u'http://path/to/ns2#'), ((None, u'attr'), u'value2')]
[((u'http://path/to/ns2#', u'attr'), u'value3')]
Successfully got child3 attr value

In the first two cases the namespaceURI is None, but it should be set to the default namespace specified in the root element.  I believe this problem occurs with all *NS functions.  Not tested in 3.x.
msg144927 - (view) Author: Jeremy Kloth (jkloth) * Date: 2011-10-04 21:32
Please read the link which you posted.  Quoting the second paragraph, second sentence:

"Default namespace declarations do not apply directly to attribute names;"

and from the third paragraph, third sentence:

"The namespace name for an unprefixed attribute name always has no value."

Therefore minidom *is* conformant by having None as the namespace-uri for unprefixed attribute names.
msg221026 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-19 21:35
From the statement in msg144927 this can be closed as "not a bug".
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57311
2014-06-20 02:35:52ezio.melottisetstatus: open -> closed
resolution: not a bug
stage: resolved
2014-06-19 21:35:06BreamoreBoysetnosy: + BreamoreBoy
messages: + msg221026
2011-10-05 04:29:21ezio.melottisetnosy: + ezio.melotti
2011-10-04 21:32:52jklothsetnosy: + jkloth
messages: + msg144927
2011-10-04 20:11:53crasscreate