Summary: FOP not supporting ErrorHandler and location not
displayed in Errors
ReportedBy: [EMAIL PROTECTED]
Created an attachment (id=22798)
Source Code for workaround, many classes in one text file.
The FOP classes hard code the use of an apachie logger, and do not allow an
ErrorHandler to be assigned.
I wanted to capture all errors for a xml parse, transform and render task, so I
could associate the errors with the subject xml file.
To achieve this I had to extend the FOTreeBuilder class to override the default
error handling with calls to a client app specified error Handler.(see
attachment: class ErrorHandlingFOTreeBuilder). In doing so I was annoyed to
find that the FOTreeBuilder.error(..) and FOTreeBuilder.warning(..) methods do
not expect the throwing of Exceptions (i.e FOTreeBuilder is almost but not
quite able to implement org.xml.sax.ErrorHandler.
Other classes within FOP use apache logging extensively, and although I see the
benefits of this logging during the development of FOP, as a client library it
would be nicer if it used ErrorHandlers. I notice that Fop does have a
defaultError handler but it is rarely used and can not be replaced by a client
The Class AreaTreeParser has the line "transformer.setErrorListener(new
DefaultErrorListener(log));". As such, to capture and handle all transformation
errors myself I had to write my own log class (see attached class CacheLogger,
and class XmlErrorCache). I understand why this line exists as Xerces has a
known bug in its default error handler and the client app must explicity set a
ErrorListener to catch all parsing errors in Xerces.
Note: Xerces has a bug in its default ErrorHandler and fails to throw some
errors correctly, to work around this you must use custom error handlers.
As an example of what difference my work around has use FOp on any valid xml/
xslt pair, then edit the xslt file and make it invalid by removing a
</fo:block> element from anywhere. Run the transformation using my code and the
standard examples and note the reported error differences.
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.