"Christian Reiniger" <[EMAIL PROTECTED]> wrote in message
01042417490700.07614@chrisbig">news:01042417490700.07614@chrisbig...
>Well, "needed to use" might be incorrect, because return value evaluation
>can be used instead (unless some functions never signal errors via their
>return value). Aside from that you're right.

OK, I will try to clarify my original problem...

At http://www.php.net/manual/en/function.xslt-process.php there is an
example program. When I use it as is, it works all right and produces a nice
table. Here is a short section of the code:
-----
[...]
if (xslt_process($xslData, $xmlData, $result)) {
[...]
} else {
echo "There was an error that occurred in the XSL transformation...\n";
echo "\tError number: " . xslt_errno() . "\n";
echo "\tError string: " . xslt_error() . "\n";
exit;
}
?>
-----

This is quite similar to what I am trying. If you now corrupts the xmlData
variable, e.g. by changing <article> to <rticl> without changing the closing
tag, you will get an error message saying

<br>
<b>Fatal error</b>:  XML parser error 7: mismatched tag in
<b>/var/www/test.php</b> on line <b>40</b><br>

As you can see here, xslt_process() dies with a fatal error and the program
is terminated, and we never get to testing the return value. The next
problem, is that since the error is "fatal", it is also not possible to use
set_error_handler() to catch the error. And placing the @-sing before the
variable only supresses the default error-message, which is not an
acceptable solution to us. The last thing I tried, was the
error_prepend_string and error_append_string in php.ini, but it is very
difficult making a valid error-message this way. Because of the unclosed
<br> tags we don't get a valid xml-message. And because of the <b> and <br>
tags, it would not comply with the error-message format we need to use
anyway. And using the @-sing causes error_append/prepend_string to be
ignored alltogether.

And in my opinion, there are too many things that can cause PHP to die with
a fatal error. So we simply *must* be able to handle it and give a valid and
reasonable error-message back.

--
Svein Roar Nilsen
Norwegian Hydrographic Services




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to