I was trying to convert one XML to another using XSLT 2.0, normally it works, but when file size is large like 1-2 MB I am getting error like java.util.concurrent.CompletionException: java.lang.StackOverflowError
Below Java code is using for the transformation
public static String doTransformation(String request, File xslTransformer)
throws TransformerException {
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer(new StreamSource(xslTransformer));
trans.setParameter("indent-elements", "yes");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
InputStream inputStream = new ByteArrayInputStream(request.getBytes());
trans.transform(new StreamSource(inputStream), new StreamResult(outputStream));
return new String(outputStream.toByteArray());
}
Library used
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>
Any help would be appreciated.