Re: [PHP-XML-DEV] xml error handling for 5.1

[email protected] (Rob Richards) Fri, 04 Feb 2005 12:01:11 -0500
Newsgroups php.xml.dev
Message-ID <[email protected]>
Christian Stocker wrote:

>
> I did some first, very basic tests. Looks promising. But 2 questions:
>
> - Can I only get the last error? Shouldn't I be able to get more? 
> Usually libxml2 throws more than one error during parsing (if there's 
> an error) and it would be nice, if I could get all of them. But 
> looking quickly at your code and the one from libxml2, you're using 
> the global error functions of libxml2, which only stores the really 
> last one. Too bad, if libxml2 would use a stack-thingie for that as 
> well, it would have been easy.

Right now you can only get the last error. I wanted to start simple it 
could at least get it into the 5.1 release and make sure this is the way 
the new error stuff should go. In order for this to happen, we will need 
to copy and stack them somehow within the 
php_libxml_structured_error_handler function. Right now its empty and 
used just to get the xmlSetStructuredErrorFunc set and suppress the 
standard error messages.

>
> - I can't check the state of libxml_use_interal_errors(false);
> Would be nice, if it would return the state before (like 
> error_reporting() does), or if used without argument, the current state.
> If I find the time, I can try to implement it. But that won't happen 
> before next week ;)

Updated patch. You can now do:
$old_state = libxml_use_interal_errors(false); and well as 
$current_state = libxml_use_interal_errors();

Rob