Update so fa on the error handling issue I have:

I've tried to implement my own ErrorListener that would propagate errors created in fop and transfer them to my java code scope.

Still errors like "Error while recovering image information" when image is not found do not raise exception -> I cannot catch them in my java agent.

The code for ErrorListener that I implemented is trivial and looks like this

------- ErrorListener implementation ---------------------
import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
import org.apache.log4j.Logger;

public class MyErrorListener implements ErrorListener {
        private static Logger logger = Logger.getLogger(JavaAgent.class);

        public MyErrorListener() {                                
                logger.info("MyErrorListener initialised");                
        }

        public void warning(TransformerException arg0) throws TransformerException {                                
                logger.warn("MyErrorListener WARN:",arg0);
                throw arg0;
        }

        public void error(TransformerException arg0) throws TransformerException {
                logger.error("MyErrorListener ERROR:",arg0);
                throw arg0;
        }

        public void fatalError(TransformerException arg0)
                        throws TransformerException {                
                logger.fatal("MyErrorListener FATAL:",arg0);
                throw arg0;
        }

}
----------------------------------------------------------------------------------------
I set this ErrorListener to the transformer like this:

               Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));                
                // Set the value of a <param> in the stylesheet
                transformer.setParameter("versionParam", "2.0");                
                MyErrorListener myErrorListener = new MyErrorListener();              
                transformer.setErrorListener(myErrorListener);
____________________________________________________

Errors like when tag missing in the xml input file that I'm transforming get propagated and raise exception, but
errors like I've written above (image file returned null) do not get piped trough my ErrorListener implementation.

Am I even on the right track ?

Thank you

Jelka



jelka.kosir@atol.si

12.12.2006 10:16
Please respond to
fop-users@xmlgraphics.apache.org

To
fop-users@xmlgraphics.apache.org
cc
Subject
How to plug in Error Handling in Fop beta






Hi !


I was looking trough the mailing list, I am sure this question was already answered but I cannot find the specific mail.


I use fop as embedded in a Notes / Domino Agent.


I would need to implement error handling, for example when Error is produced in process of transformation xml to pdf

I would need fop to throw exception so I could catch it in my Embedded agent and process further on.


I also set up logging with Log4J and I would like in case of error in fop transformation to dump the contents of xml file to error log
(to be able to reproduce the error).


As I am not familiar in Java programming as much I am looking for any documentation I would follow to

set up error handling as described.


Could someone be so kind and instruct  me on this matter (maybe paste a useful link if there is any)?


Thank you


Jelka