我有這個樣式表撒克遜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」',但它只能給出警告,而不是錯誤。 –