Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.7
-
None
-
None
-
Windows XP Home, Java 1.5
Description
To prevent the processing of erroneous XSLT stylesheets, I wanted to add a ErrorListener which throws an error even if the warning function is called. As the warning function does not allow throwing a TransformerException, it wrap it in a RuntimeException:
static class XMLErrorListener implements ErrorListener {
public void warning(TransformerException exception)
{ throw new RuntimeException(exception); }I however noticed that I got fewer errors than were logged before. I found out that the function org.apache.xml.serializer.ToXMLStream.addAttribute() contains a catch (Exception e) {} clause which swallows all exception thrown. Swallowing all exceptions is IMHO considered bad style. I see no reason why I should not be able to decide that I want to treat even warnings as errors and stop processing immediately.
Other XSLT warnings do not swallow a thrown exception and therefore allow me to stop the processing.