Xslt 撒克逊变换
我有这个样式表Xslt 撒克逊变换,xslt,soap,saxon,Xslt,Soap,Saxon,我有这个样式表 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://testwork/"> <xsl:template
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tes="http://testwork/">
<xsl:template match="/">
<xsl:apply-templates select="soapenv:Envelope/soapenv:Body/*"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
但是在方法的执行过程中,我有一个错误
javax.xml.transform.TransformerConfiguration异常:未能
编译样式表。检测到1个错误。
位于net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:220)
位于net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:132)
位于net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:87)
位于service.ResponseService.getRequestSoapBody(ResponseService.java:76)
有什么问题吗?第一个问题是没有显示编译器错误消息。默认情况下,Saxon会将消息发送到System.err,但是如果您在一个具有图形用户界面的应用程序中,您很可能永远看不到其中所写的内容。因此,将消息重定向到其他地方。您可以使用System.setErr()将其指向GUI应用程序中的文件或窗口;还有一些Saxon级别的控件可以将不同编译的输出发送到不同的目的地 你给我们看的代码没有问题
我怀疑(但这只是猜测)您的变量“xsl”包含作为字符串的样式表代码,而它应该包含样式表位置的URI。我已经测试了您的代码,从命令行运行Saxon 9.5 HE,它没有给出错误。你到底用哪个版本?代码中唯一奇怪的事情是XSLT2.0处理器的
version=“1.0”
,但这只会给出警告,而不是错误。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://testwork/">
<soapenv:Header/>
<soapenv:Body>
<tes:sayHelloWorldFrom>
<!--Optional:-->
<arg0>?</arg0>
</tes:sayHelloWorldFrom>
</soapenv:Body>
</soapenv:Envelope>
public void get(String xml, String xsl) throws ServiceException {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(xsl));
transformer.transform(new StreamSource(xml), new StreamResult(System.out));