Re: [xml] question regarding error reporting



On Wed, Aug 04, 2004 at 04:44:18PM -0700, Mark Vakoc wrote:
Hi Daniel, all,

I've got a question on the error/warning reporting mechanism.  I've got custom
error functions defined and are used to redirect errors/warnings to a log file.
 
Part of my application performs relax-ng validation, however any
errors/warnings generated by the relaxng portion aren't really "errors" so I
redirect them to different error handlers using xmlRelaxNGSetValidErrors()
which works fine.

The issue is by doing so I miss a lot of the information that is normally
printed out, such as source file, line, error domain, etc.  Going through the
code I notice at the tail in of __xmlRaiseError
...
  if ((channel == xmlParserError) ||
        (channel == xmlParserWarning) ||
      (channel == xmlParserValidityError) ||
      (channel == xmlParserValidityWarning))
      xmlReportError(to, ctxt, str, NULL, NULL);
    else if ((channel == (xmlGenericErrorFunc) fprintf) ||
             (channel == xmlGenericErrorDefaultFunc))
      xmlReportError(to, ctxt, str, channel, data);
    else
      channel(data, "%s", str);
...

that xmlReportError which generates that extra info from the xmlLastError (to)
is only called if channel (in this case xmlRelaxNGValidCtxt.error) is fprintf

Is there a reason that xmlReportError isn't called regardless of what error
handler channel points to?

  I think that the point was to make a single callback in case a structured
error handler has been set-up (xmlReportError makes at least 2 calls IIRC).
The expectation is that the structured error handler will find informations
like the source file and line number from data or the global error variable.
I.e. fprintf is not a structured error reporting mechanism, it's string based,
so it can be called multiple times for one error, on the other hand the user
callback is structured and should be called only once per error. I think it's
the reason for this dichotomy.

Daniel

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



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