2013-08-23 96 views
2

我打电话嵌入响应XML作为逃脱XML Web服务逃脱XML和UNESCAPE。我收到完整的SOAP响应,但只对'转义的XML'部分感兴趣()。检索使用XSLT 1.0

我试图写一个XSL(1.0)来检索逃脱XML和UNESCAPE,所以我可以通过其他非XSLT组件对其进行处理。

我已经尝试了一些其他的解决方案,在StackOverflow中'unescaping',但没有运气。从Web服务

响应

<?xml version="1.0" encoding="UTF-8"?> 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body> 
     <SendMessageResponse xmlns="http://www.company.com/CAIS"> 
      <SendMessageResult>&lt;?xml version="1.0"?&gt;&lt;IEXInboundServiceResponse&gt;&lt;IEXInboundServiceResponseVersion&gt;1.0&lt;/IEXInboundServiceResponseVersion&gt;&lt;ServiceResponse&gt;IEX_SUCCESS&lt;/ServiceResponse&gt;&lt;RequestMessageId&gt;22658651-024E-445B-96C1-94F027205E01&lt;/RequestMessageId&gt;&lt;/IEXInboundServiceResponse&gt;</SendMessageResult> 
     </SendMessageResponse> 
    </s:Body> 
</s:Envelope> 
进行反向转义

<?xml version="1.0"?> 
<IEXInboundServiceResponse> 
    <IEXInboundServiceResponseVersion>1.0</IEXInboundServiceResponseVersion> 
    <ServiceResponse>IEX_SUCCESS</ServiceResponse> 
    <RequestMessageId>22658651-024E-445B-96C1-94F027205E01</RequestMessageId> 
</IEXInboundServiceResponse> 

当前XSLT后

所需的输出,我使用

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="xml" version="1.0" indent="yes" omit-xml-declaration="yes"/> 

    <xsl:template match="//SendMessageResult"> 
     <xsl:value-of select="." disable-output-escaping="yes" /> 
    </xsl:template> 

</xsl:stylesheet> 

帮助!

感谢

大卫

+1

您是否想要显示您尝试使用的XSL,以便我们可以帮助指出该区域进行更正? –

+0

嗨凯文,我编辑了原来的帖子,包括我一直使用的XSLT。 –

回答

2

的问题是对付你正在使用的命名空间。首先,您尚未在XSLT中声明http://www.company.com/CAIS namspace。您可以通过将第一行更改为:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" 
       xmlns:c="http://www.company.com/CAIS"> 

请注意最后的命名空间。我尝试了一个空白的命名空间,但它仍然存在与您一样的问题。

然后更改模板开行到:

<xsl:template match="//c:SendMessageResult"> 

那么就应该按预期工作。

+0

真棒,感谢乐高。像魅力一样工作。干杯,大卫。 –