You have to dive down to the Controller that underpins the XsltTransformer (available via getUnderlyingController()) and call its setErrorListener() method to supply a suitable ErrorListener. The ambiguous template messages are sent to the ErrorListener's warning() method.
I haven't exposed this in s9api yet because I haven't made the decision whether to expose the JAXP interface directly or to wrap it in something a little more user-friendly. I could even integrate it with the MessageListener.
Michael Kay

From: Cuzner Stephen P []
Sent: 19 March 2009 19:52
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: [saxon] Capturing error messages

I've got a small Java app that uses the s9api.XslTransformer. I've implemented a MessageListener to capture any messages and log them with log4j, info for terminate=no, fatal for terminate=yes. That works great. However I've run into a recoverable error with some ambiguous templates that get output to stderr. I intend to fix my stylesheet, but I'd rather make sure that all output is trapped with my log4j logger. Is there any way to do this?