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

StackOverflow https://stackoverflow.com/questions/23628771

  •  21-07-2023
  •  | 
  •  

I am facing issue while converting xml to html using xslt
dummy code as follow.

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 as Follow:

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.'

my xml and xslt files are proper.If I use same code main method for testing its working fine but same code not parsing in project. any idea???

有帮助吗?

解决方案

I believe that there might be some library conflict or version different in your environment. Please check all related libraries.

It seems that you have closed the stream while transformer is still doing the work. Please check that you have not closed any stream resources.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top