Re: [xml] question about how to set namespace in libxml
- From: Daniel Veillard <veillard redhat com>
- To: xml gnome org
- Subject: Re: [xml] question about how to set namespace in libxml
- Date: Mon, 7 Mar 2011 17:37:29 +0800
On Sun, Mar 06, 2011 at 05:30:25PM +0100, Michael Ludwig wrote:
Daniel Veillard schrieb am 06.03.2011 um 22:18 (+0800):
On Sun, Mar 06, 2011 at 12:43:23PM +0100, Michael Ludwig wrote:
But what about the question I raised? Is it possible to turn off
namespace awareness with libxml2 using any of the other parsers?
* using the DOM parser?
* using the SAX parser?
* using the pull parser (XML reader)?
Well actually I consider this a bug, the fact that the XML is not
namespace compliant should not make the ns: prefixes disapear. It used
to be true and it broke at some point. IMHO there should be no flag
to pass it's just a bug. I should probably investigate.
Merci! What I wanted to know is if there is an option to just turn off
namespaces, so a document such as the one the OP posted is well-formed
(which it is), just not namespace-well-formed. Users might then choose
whether they want the parser to do namespaces or not.
I do think the parser should accept XML-1.0 circa 1997 document
without the need for a parser flag !
Ah, I think you're saying that namespace declarations (xmlns attributes)
will cause the parser to do namespaces while colonized names without
namespace declarations should still parse fine?
No basically the fact that the document is not namespace aware
should not change the way it's parsed, basically the missing xmlns
should not affect parsing :
- document is returned (it's well formed, not a fatal error)
- a namespace error is issued (but application can ignore it)
- the names generated in the document should use foo:bar
the parser works for 1/ and 2/ but fails on 3/ and I think it's a
regression, but I don't know when it was introduced.
But wouldn't that raise problems when there are *some* namespace
declarations but also some colonized names which the doc does not
account for with namespace declarations? Would the document then fall
into a grey zone between namespace-well-formed and just well-formed?
And wouldn't it be clearer if users communicated their intentions by
passing a flag to turn namespaces off, or on?
Basically the document is not namespace well-formed. I think that
parts where the namespace is found should be reported adequately, but
part where the namepspace is missing the original name with the column
should be passed to the application (along with the error of course !)
From a spec POV it's a grey area because the APIs aren't defined and
and document is well-formed but not namespace well-formed, but I don't
see why one behaviour should be mandated rather than another one (except
the document is 1.0 WF so must parse fully)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel veillard com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]