错误:'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException:XML文档结构必须在同一实体内开始和结束

时间:2014-05-13 10:28:54

标签: java xml xslt

使用xslt将xml转换为html时遇到问题
虚拟代码如下。

TransformerFactory tFactory = TransformerFactory.newInstance();
Source xslDoc = new StreamSource( xsltPath );
Source xmlDoc = new StreamSource( xmlPath );
oFileOutputStream=new FileOutputStream( htmlOutputPath );
htmlFile = oFileOutputStream;
Transformer transformer = tFactory.newTransformer( xslDoc );
transformer.transform( xmlDoc, new StreamResult( htmlFile ) );

错误如下:

ERROR:  'XML document structures must start and end within the same entity.'
ERROR:  'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: XML document structures must start and end within the same entity.'

我的xml和xslt文件是正确的。如果我使用相同的代码主方法来测试其工作正常但相同的代码不在项目中解析。 任何的想法???

1 个答案:

答案 0 :(得分:0)

我相信您的环境中可能存在某些库冲突或版本不同。请检查所有相关的库。

当变压器仍在进行工作时,您似乎已关闭了流。请检查您是否未关闭任何流资源。