We have data as XML and there are multiple formatting XSL styles. It was working fine till now in IE.
Then, We needed to display the same content as HTML in Chrome. So, We found an API on server side (Java) to transform XML+XSL to HTML.
public static String convertXMLXSL(String xml, String xsl) throws SQLException {
System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
TransformerFactory tFactory = TransformerFactory.newInstance();
String html = "";
try {
try {
StreamResult result = new StreamResult(new StringWriter());
**Transformer trans = tFactory.newTransformer(new StreamSource(new ByteArrayInputStream(xsl.getBytes("utf-8"))));
trans.transform(new StreamSource(new ByteArrayInputStream(xml.getBytes("utf-8"))), result);**
html = result.getWriter().toString();
} catch (TransformerException te) {
te.printStackTrace();
}
} catch (Exception e) {
AppendExceptionToLog(e);
}
return html;
}
But, Now after sometime, We see some thread dumps which are blocked at trasform method of javax.xml.transform.Transformer
Sep 12, 2017 12:07:49 PM org.apache.catalina.valves.StuckThreadDetectionValve notifyStuckThreadDetected
WARNING: Thread "http-8080-12" (id=15800) has been active for 6,516 milliseconds (since 9/12/17 12:07 PM) to serve the same request for
and may be stuck (configured threshold for this StuckThreadDetectionValve is 5 seconds).
There is/are 3 thread(s) in total that are monitored by this Valve and may be stuck.
java.lang.Throwable
at org.apache.xpath.axes.AxesWalker.getNextNode(AxesWalker.java:333)
at org.apache.xpath.axes.AxesWalker.nextNode(AxesWalker.java:361)
at org.apache.xpath.axes.WalkingIterator.nextNode(WalkingIterator.java:192)
at org.apache.xpath.axes.NodeSequence.nextNode(NodeSequence.java:281)
at org.apache.xpath.axes.NodeSequence.runTo(NodeSequence.java:435)
at org.apache.xpath.axes.NodeSequence.setRoot(NodeSequence.java:218)
at org.apache.xpath.axes.LocPathIterator.execute(LocPathIterator.java:210)
at org.apache.xpath.XPath.execute(XPath.java:335)
at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:278)
at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:246)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2281)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1367)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:709)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1284)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1262)
at Util.processXMLXSL(Util.java:3364)
Here, I wanted to know..
1) Do we have any other known implementation do the same on server side ?
2) Should I consider using client side approach using XSLTProcessor of Mozilla ?