I've written an ErrorListener and attached it to both net.sf.saxon.TransformerFactoryImpl and the transformer created by the factory.  I catch XSL syntax errors just fine.  Yet errors in XML structure (missing/extra tag, etc.) cause a SXX0003 XML parse error which is not caught by the error listener. This error is printed in the error console.  I need to capture this error and display the reason for the error to the developer writing/testing the XSL.  Odd thing is, when a single imported template can't be parsed, the other XSL files are still loaded and parsed so that a whole slew of unrelated errors are thrown because of the missing imported template.  The real reason for this (the XML can't be parsed) is the one reason not sent to the error listener.  Is there a way to capture these messages?

The code:

    ArrayList<TransformerException> errorList = new ArrayList<TransformerException>();
    ErrorListener listener = new ErrorListener() {
       
        public void error(TransformerException exception) throws TransformerException
        {
            Log logger = LogFactory.getLog(MODE.toUpperCase());
            logger.error("TRANSFORMXML ERROR:"+exception.getMessageAndLocation());
            errorList.add(exception);
        }

        public void fatalError(TransformerException exception) throws TransformerException
        {
            Log logger = LogFactory.getLog(MODE.toUpperCase());
            logger.fatal("TRANSFORMXML ERROR:"+exception.getMessageAndLocation());
            errorList.add(exception);
            throw exception;
        }

        public void warning(TransformerException exception) throws TransformerException
        {
            Log logger = LogFactory.getLog(MODE.toUpperCase());
            logger.warn("TRANSFORMXML WARNING:"+exception.getMessageAndLocation());
            errorList.add(exception);
        }
    };
   
    try
    {
        tranFactory = new net.sf.saxon.TransformerFactoryImpl(SAXON_CONFIGURATION);
        tranFactory.setErrorListener(listener);
        aTransformer = tranFactory.newTransformer( source );
        aTransformer.setErrorListener(listener);
    }
    catch( javax.xml.transform.TransformerException e1 )
    {
        handleException(e1);
    }