[issue18182] xml.dom.createElement() does not take implicit namespaces into account
karl
report at bugs.python.org
Thu Sep 26 08:45:20 EDT 2019
karl <karl+pythonbugs at la-grange.net> added the comment:
The current specification as of today documents
https://dom.spec.whatwg.org/#dom-document-createelementns
If you run this in the browser console,
var nsdoc = 'http://foo.bar/zoo';
var xmldoc = document.implementation.createDocument(nsdoc, 'Zoo', null);
var cpd = document.createElementNS(nsdoc, 'Compound');
var chimp = document.createElementNS(nsdoc, 'Chimp');
cpd.appendChild(chimp)
xmldoc.documentElement.appendChild(cpd);
/* serializing */
var docserializer = new XMLSerializer();
var flatxml = docserializer.serializeToString(xmldoc);
flatxml
you get:
<Zoo xmlns="http://foo.bar/zoo">
<Compound>
<Chimp/>
</Compound>
</Zoo>
but if you run this in the browser console,
var nsdoc = 'http://foo.bar/zoo';
var xmldoc = document.implementation.createDocument(nsdoc, 'Zoo', null);
var cpd = document.createElement('Compound');
var chimp = document.createElement('Chimp');
cpd.appendChild(chimp)
xmldoc.documentElement.appendChild(cpd);
/* serializing */
var docserializer = new XMLSerializer();
var flatxml = docserializer.serializeToString(xmldoc);
flatxml
you get:
<Zoo xmlns="http://foo.bar/zoo">
<compound xmlns="http://www.w3.org/1999/xhtml">
<chimp></chimp>
</compound>
</Zoo>
which is a complete different beast.
I don't think there is an issue here. And we can close this bug safely.
----------
nosy: +karlcow
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue18182>
_______________________________________
More information about the Python-bugs-list
mailing list