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



Daniel,

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
this?  

Thanks,

Greg

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

I am trying to find out why a missing namespace
declaration was made a FATAL error in 2.6.x?  We
use
libxml to parse 'snippets' of XML that are missing
the
namespace declarations by design.  We used to set
the
ignore warnings flag in the older libxml, but are
considering an upgrade to 2.6.6 now, and
discovering
that the only way to make libxml 'happy' is to
surround the document with a dummy root node that
has
the namespace declarations prior to parsing, and
removing them when dumping.  Would it be possible
to
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
definitions.
It's the first time someone complains about the new
parser behaviour,
in itself it's an interesting point.

Daniel

-- 
Daniel Veillard      | Red Hat Network
https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit
 http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you?re looking for faster
http://search.yahoo.com



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