0
我正在尝试编写xslt
来修改xml
。这是由同步呼叫接收的响应。这个XML的结构需要被修改,并且数据需要被传输,这样响应可以被原始系统消耗。无法使用Xslt获取提取元素
输入XML是如下:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
<SOAP-ENV:Body>
<ns0:ValidateMeterItemResponse xmlns:ns0="http://www.apsc.com/CCB/ValidateMeterItem/InOut">
<ns1:ValidateMeterItemRes xmlns:ns1="http://www.apsc.com/CCB/MeterServices/InOut">
<ns1:verificationStatus>M2IV</ns1:verificationStatus>
<ns1:errorCode>256.0</ns1:errorCode>
<ns1:errorText>Service Point ID 1245765566 field invalid</ns1:errorText>
<ns1:readingDetails/>
</ns1:ValidateMeterItemRes>
</ns0:ValidateMeterItemResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
预期输出XML是:
<responseMessage/">
<response>
<errorCode>256.0</errorCode>
</response>
</responseMessage>
我想只提取只有一个节点现在。
下面是我写的XSLT。我首先按原样复制了所有元素,然后试图取消<ValidateMeterItemResponse>
节点。然后,我尝试通过使用xsl value of
从输入xml中选择某些元素来构建我的xml(使用不同的结构)。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://xmlns.oracle.com/OUMWM/Message"
xmlns:ns1="http://xmlns.oracle.com/OUMWM/Message1">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="/*/*/*">
<xsl:apply-templates select="node()" />
</xsl:template>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<responseMessage>
<response>
<errorCode>
<xsl:value-of select="SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:ValidateMeterItemRes/ns1:errorCode" />
</errorCode>
</response>
</responseMessage>
</xsl:template>
</xsl:stylesheet>
即使所有路径都正确,我仍无法提取元素。我确信我错过了一些尝试完成此事的东西。我哪里做错了?
喜添,非常感谢您!!感谢你的帮助!!有效! –