这是我的过滤器:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xsl:template match="Table1/*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Table1">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xs:schema">
</xsl:template >
<xsl:template match="sMessage">
</xsl:template >
</xsl:stylesheet>
这是我的XML:
<GetWorkOrderListResponse xmlns="http://buildfolio.com/TamesWebSvs/">
<GetWorkOrderListResult>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table1 diffgr:id="Table11" msdata:rowOrder="0" diffgr:hasChanges="inserted">
<WR_ID>862</WR_ID>
<WR_NO>RP-WO302</WR_NO>
</Table1>
<Table1 diffgr:id="Table12" msdata:rowOrder="1" diffgr:hasChanges="inserted">
<WR_ID>722</WR_ID>
<WR_NO>TT12012-WO263</WR_NO>
</Table1>
</NewDataSet>
</diffgr:diffgram>
</GetWorkOrderListResult>
<sMessage>Download Success!</sMessage>
</GetWorkOrderListResponse>
我无法从输出中删除sMessage节点。我的输出包含文本Download Success!,我试图摆脱它。我错过了什么? 感谢。
答案 0 :(得分:1)
您缺少的是您的XML文档具有默认命名空间:
xmlns="http://buildfolio.com/TamesWebSvs/"
通过作用域继承,sMessage元素位于该命名空间中。要匹配它,您需要告诉匹配在该命名空间中查找sMessage:
<xsl:template match="tws:sMessage" xmlns:tws="http://buildfolio.com/TamesWebSvs/">