我有这个样式表撒克逊transfromation
<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>
与此XML文件
<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>
我想从这个XML与此XSL得到一个身体,我使用撒克逊进行了改造,在这里它是我的一段代码
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));
但该方法的执行过程中我有一个错误
javax.xml.transform.TransformerConfigurationException:无法通过 编译样式表。检测到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) at service.ResponseService.getRequestSoapBody(ResponseService.java:76)
那么,怎么了?提前Thanx
我测试了你的代码,从命令行运行Saxon 9.5 HE,并且它没有提供错误。你使用哪个版本?你的代码中唯一奇怪的事情是XSLT 2.0处理器的'version =“1.0”',但它只能给出警告,而不是错误。 –