相关疑难解决方法(0)

TransformerFactory.newInstance().newTransformer(streamSource) 返回 null

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
Run Code Online (Sandbox Code Playgroud)

这是输出:

--Output from testTransformation--
java.io.BufferedInputStream@32999f10
javax.xml.transform.stream.StreamSource@399ed64
org.apache.xalan.processor.TransformerFactoryImpl@6eb04214
null

java xslt groovy xalan

2
推荐指数
1
解决办法
3644
查看次数

标签 统计

groovy ×1

java ×1

xalan ×1

xslt ×1