GNOME Bugzilla – Bug 324434
<xmlns:xmlns/> yields in namespace error
Last modified: 2021-07-05 13:23:21 UTC
% perl -e "print '<xmlns:xmlns/>'" | xmllint - 1.xml:1: namespace error : Namespace prefix xmlns on xmlns is not defined <xmlns:xmlns/> ^ <?xml version="1.0"?> <xmlns/> % xmllint --version xmllint.exe: using libxml version 20619CVS2407 compiled with: DTDValid FTP HTTP HTML C14N Catalog XPath XPointer XInclude Iconv Unicode Regexps Automata Schemas Modules
There is a namespace error, though not about not being defined http://www.w3.org/TR/REC-xml-names/#nsc-NSDeclared "The prefix xmlns is used only for namespace bindings and is not itself bound to any namespace name." using xmlns for something else than defining a namespace binding is an error, which should be reported as such, not as being undefined. Daniel
Well, it's "The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. It must not be declared. No other prefix may be bound to this namespace name." The relevant text would be "The namespace prefix, unless it is xml or xmlns, must have been declared in a namespace declaration attribute in either the start-tag of the element where the prefix is used or in an an ancestor element". Your interpretation of "is used" to mean "MUST NOT be used for anything but" isn't really backed up by the Recommendation or related specifications, e.g. createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns') would not raise a NAMESPACE_ERR in DOM implementations and <xmlns:xmlns/> is the only way to serialize that.
This is a grey area. The createElementNS issue was actually brought up on the W3C list years back and a few people said it should raise a NAMESPACE_ERR yet the issue was never addressed. IMO, the interpretation libxml2 uses is correct and the recommendation and specs are just too vauge about it.
Yes I still think we should raise a namespace error in such case, just that maybe it should be a different error message. So I'm not rushing to 'fix' that one, there is something to be done, so I'm not closing the bug but I'm not 100% sure how best handle those case. Daniel
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.