How could that be that TransformerFactory.newInstance().newTransformer(streamSource) returns null. According to javadoc this is not possible: http://download.oracle.com/javase/6/docs/api/javax/xml/transform/TransformerFactory.html#newTransformer(javax.xml.transform.Source)
here's groovy code sample
def is = new ClassPathResource('xslt/MySpace-Contact.xsl').inputStream
println is
def streamSource = new StreamSource(is)
println streamSource
def factory = TransformerFactory.newInstance()
println factory
def tr = factory.newTransformer(streamSource)
println tr
Here's the output:
--Output from testTransformation--
java.io.BufferedInputStream@32999f10
javax.xml.transform.stream.StreamSource@399ed64
org.apache.xalan.processor.TransformerFactoryImpl@6eb04214
null
Answering my own question. If XSLT file is not valid, that will happen (newTransformer(Source) will return
null
). I think that should be reported to Oracle so they change the javadoc. It's still POSSIBLE thatnull
is returned.