Re: [xml] Ability to make parser ignore the XML_NS_ERR_UNDEFINED_NAMESPACE error


Thanks for youur quick response.  And thanks for the
suggestion on filtering errors by domain.  I havent
explored the new structured errors to the full extent
yet, I'll look into it.  

I did notice that libxml continues to parse the tree,
but I wasn't sure whether we can count on this
behaviour staying in the future releases.  Also the
comment before xmlNsError declaration  
(Handle a fatal parser error, i.e. violating
Well-Formedness constraints) mislead me shomewhat.

What you are suggesting will work for us except for
one little detail:  When the tree parsed in such a
way, is dumped, namespaces with missing declarations
are stripped from the output.  Any way of going around



--- Daniel Veillard <veillard redhat com> wrote:
On Tue, Mar 09, 2004 at 04:43:20PM -0800, Greg
Shtilman wrote:

I am trying to find out why a missing namespace
declaration was made a FATAL error in 2.6.x?  We
libxml to parse 'snippets' of XML that are missing
namespace declarations by design.  We used to set
ignore warnings flag in the older libxml, but are
considering an upgrade to 2.6.6 now, and
that the only way to make libxml 'happy' is to
surround the document with a dummy root node that
the namespace declarations prior to parsing, and
removing them when dumping.  Would it be possible
provide a flag, or some other means (such as the
ability to predefine the namespaces) to make these
warnings ignorable in such a case?

paphio:~/XML -> cat tst2.xml
<doc s:b="foo"/>
paphio:~/XML -> xmllint tst2.xml
tst2.xml:1: namespace error : Namespace prefix s for
b on doc is not defined
<doc s:b="foo"/>
<?xml version="1.0"?>
<doc b="foo"/>
paphio:~/XML ->

  it is a namespace error, not a well-formedness
error. libxml2
still continues to parse the document and produce a
tree in that case.
You can filter errors by domain and catch namespace
errors. See 
<libxml/xmlerror.h> for a the associated APIs and
It's the first time someone complains about the new
parser behaviour,
in itself it's an interesting point.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

Do you Yahoo!?
Yahoo! Search - Find what you?re looking for faster

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]