我们将数据作为XML使用,并且存在多种格式化XSL样式。在IE中它一直工作得很好。使用Java在HTML中转换XML + XSL
然后,我们需要在Chrome中显示与HTML相同的内容。所以,我们在服务器端(Java)找到一个API来将XML + XSL转换为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;
}
但是,现在后的某个时间,我们看到被封锁在trasform的javax.xml.transform.Transformer中的方法
Sep 12, 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)
这里是一些线程转储,我想知道。
1)我们有没有其他已知的实现在服务器端做同样的事情?
2)我应该考虑使用客户端方法使用Mozilla的XSLTProcessor?
+0
时是否与输入XML独立运行XSL提供正确的HTML输出,说在Eclipse IDE? –
+0
问题不在于输出。它与代码所花费的时间。 –