TransformerFactory.newInstance().newTransformer(streamSource) 怎么可能返回 null。根据javadoc,这是不可能的:http: //download.oracle.com/javase/6/docs/api/javax/xml/transform/TransformerFactory.html#newTransformer(javax.xml.transform.Source)
这是 groovy 代码示例
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
这是输出:
--Output from testTransformation--
java.io.BufferedInputStream@32999f10
javax.xml.transform.stream.StreamSource@399ed64
org.apache.xalan.processor.TransformerFactoryImpl@6eb04214
null