Re: [xml] Uuugly warnings - repost

On Mon, Aug 26, 2002 at 10:52:52AM -0700, Gianni Mariani wrote:

I'm sorry if I persist but I have no good answer to this question.  I've 
looked through the code, I've read the docs, I have no idea why this 
does not work or the correct way to make this work.

An RTFM pointer would be fine.

My objective is to remove all output from the xml library.  In this 
case, the non-existance of the file being parsed is not considered an 
error yet the `warning: failed to load external entity 
"system_config.xml"' warning persists.  It seems as though the 
xmlParseFile API is inadequate for this.  What would be more appropriate ?


- original post....

So, I get the following output when I try to open a file using 

warning: failed to load external entity "system_config.xml"

This is the code chunk

 warningSAXFunc        l_warning = xmlDefaultSAXHandler.warning;
 errorSAXFunc          l_error = xmlDefaultSAXHandler.error;

 xmlDefaultSAXHandler.error = 0;
 xmlDefaultSAXHandler.warning = 0;

 doc = xmlParseFile(_filename.c_str());

 xmlDefaultSAXHandler.error = l_error;
 xmlDefaultSAXHandler.warning = l_warning;

So what's the Right(TM) way to send all warnings/errors to the bit bucket ?

  Okay, my guess is the following:
   - the library ain't initialized when you overwrite the default handlers
     (purist viewpoint you should use NULL, not 0)
   - then you call xmlParseFile()
   - the library notes it's not initialized, then call xmlInitParser();
   - and the default xmlDefaultSAXHandler.error and warning get overwritten

try to call xmlInitParser() before resetting the xmlDefaultSAXHandler fields.

  Another way is to reset the default error callback to your own
routine with xmlSetGenericErrorFunc() and make that routine do nothing 
(usually trivial ;-)


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

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