Hi, Richard. Richard Jones <[EMAIL PROTECTED]> wrote on 2008-06-24 11:54:08 AM: > Transformer transformer = tFactory.newTransformer(xslt); > > and am finding that "transformer" is null. This is confusing, as the > javadocs are explicit on the subject: > > > newTransformer > > public abstract Transformer <http://xml.apache.org/xalan- > j/apidocs/javax/xml/transform/Transformer.html> *newTransformer*(Source < > http://xml.apache.org/xalan-j/apidocs/javax/xml/transform/Source.html> source) > throws TransformerConfigurationException < > http://xml.apache.org/xalan- > j/apidocs/javax/xml/transform/TransformerConfigurationException.html> > > *Returns:* > A |Transformer| object that may be used to perform a > transformation in a single |Thread|, never |null|.
This is a bug. See XALANJ-2376.[1] The source of the problem was that earlier versions of JAXP stated that the default ErrorListener must simply report any error in System.err output stream, but never throw exceptions, even in the case of a fatalError. But how could a processor possibly return something useful from newTransformer if it had suffered a fatal error? The Xalan-J developers saw only two choices - throw the exception, despite the fact that the ErrorListener is supposed to dictate whether an exception is thrown, or return null, so that the user would at least be alerted to the problem by the subsequent NullPointerException. The JAXP Expert Group considered the problem, and decided that the processor should be permitted to throw the exception in the event of a fatal error, even if the installed ErrorListener chose not to throw it. So we made the wrong guess on the outcome, and we haven't yet fixed it. The work-around is to install an ErroListener that always throws the reported exception from its fatalError method. I hope that helps. Thanks, Henry [1] https://issues.apache.org/jira/browse/XALANJ-2376 ------------------------------------------------------------------ Henry Zongaro XML Transformation & Query Development IBM Toronto Lab T/L 313-6044; Phone +1 905 413-6044 mailto:[EMAIL PROTECTED]