Re: [xml] namespace error while parsing an xml(not a valid UR)
- From: Daniel Veillard <veillard redhat com>
- To: JEGA <jegan s gmail com>
- Cc: xml gnome org
- Subject: Re: [xml] namespace error while parsing an xml(not a valid UR)
- Date: Wed, 31 Oct 2012 13:26:47 +0800
On Tue, Oct 30, 2012 at 07:41:53PM +0000, JEGA wrote:
Hi
I get namespace error while parsing the below xml. I am using libxml2-2.9.0.
<node xmlns=" urn:microsoft-com:wmc-1-0"/>
According to a very old mail
chain<https://bugzilla.gnome.org/show_bug.cgi?id=570365>this should
give a warning.
This used to be a warning in libxml2-2.6.30. But now it is an error.
Is there anyway to achieve the old behaviour in the latest libxml2-2.9.0?
The actaul error message is given below.
xmllint --debug test.xml test.xml:3: namespace error : xmlns: '
urn:microsoft-com:wmc-1-0' is not a valid URI
<node xmlns=" urn:microsoft-com:wmc-1-0"/>
^
Yeah, it's a relatively complex issue, hence a reply which is a bit
long, but here it is :-) :
http://www.w3.org/TR/REC-xml-names/#ns-decl
"The attribute's normalized value MUST be either a URI reference â the
namespace name identifying the namespace â or an empty string."
the bug you reference is really about the normalization aspect and
the conclusion is that libxml2 parser should not remove the leading
space (that is related to the parsing level).
Now the MUST in the Namespace specification has to be interpreted
according to http://www.w3.org/TR/REC-xml-names/#keywords
-------
1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that the
definition is an absolute requirement of the specification.
-------
http://www.w3.org/TR/REC-xml-names/#Conformance
By the violation of this MUST constraint (assuming I'm right in that
interpretation) then the document is not namespace-well-formed.
This is then clearly an "error" not a "warning".
then we hit the conformance point:
http://www.w3.org/TR/REC-xml-names/#ProcessorConformance
--------
To conform to this specification, a processor MUST report violations of
namespace well-formedness, with the exception that it is not REQUIRED to
check that namespace names are URI references [RFC3986].
--------
So repporting that error is not required to be conformant, but that's
where I will have an opinion, libxml2 should report it because in the
end it's an error, we have the opportunity to report it, and we should.
It's espcailly nasty as such errors may be quite hard to find visually
but will break for example all XPath processing which is based on an
exact string match of the namespace name.
I hope I didn't get that wrong !
You may filter it out if you want, just catch it and ignore it.
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]