具有多个命名空间的 SOAP 响应的 XSLT 转换
XSLT Transformation of a SOAP Response with multiple namespace
我一直在尝试转换 SOAP 响应,据我所知,我尝试了很多方法,下面是我编写的 XML 和 XSL,我似乎无法获得任何节点的值。
下面是 xml :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateCallResponse xmlns="http://tempuri.org/">
<CreateCallResult xmlns:a="http://schemas.datacontract.org/2004/07/ServiceCallCreate" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ParameterList>
<a:Paramname>errorstate</a:Paramname>
<a:ParamValue>0</a:ParamValue>
</a:ParameterList>
<a:ParameterList>
<a:Paramname>errorstring</a:Paramname>
<a:ParamValue/>
</a:ParameterList>
<a:ParameterList>
<a:Paramname>newcallid</a:Paramname>
<a:ParamValue>160901-0083</a:ParamValue>
</a:ParameterList>
</CreateCallResult>
</CreateCallResponse>
</s:Body>
</s:Envelope>
下面是 XSL:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope"
xmlns:a="http://schemas.datacontract.org/2004/07/ServiceCallCreate"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:k="http://tempuri.org" exclude-result-prefixes="s k i a">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="utf-8" indent="yes" />
<xsl:template match="/">
<CreateCallResponse>
<ErrorCode>
<xsl:value-of select="s:Envelope/s:Body/k:CreateCallResponse/i:CreateCallResult/a:ParameterList/a:ParamValue" />
</ErrorCode>
</CreateCallResponse>
</xsl:template>
</xsl:stylesheet>
请大家帮我看看哪里做错了。
在样式表中,您没有使用输入中的 URI,因此将样式表中的 xmlns:k="http://tempuri.org"
更改为 xmlns:k="http://tempuri.org/"
,并将 xmlns:s="http://schemas.xmlsoap.org/soap/envelope"
更改为 xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
,然后更改<xsl:value-of select="s:Envelope/s:Body/k:CreateCallResponse/k:CreateCallResult/a:ParameterList/a:ParamValue" />
的路径。但是,我不确定您想要输入的哪个 ParamValue
。
我一直在尝试转换 SOAP 响应,据我所知,我尝试了很多方法,下面是我编写的 XML 和 XSL,我似乎无法获得任何节点的值。
下面是 xml :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateCallResponse xmlns="http://tempuri.org/">
<CreateCallResult xmlns:a="http://schemas.datacontract.org/2004/07/ServiceCallCreate" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ParameterList>
<a:Paramname>errorstate</a:Paramname>
<a:ParamValue>0</a:ParamValue>
</a:ParameterList>
<a:ParameterList>
<a:Paramname>errorstring</a:Paramname>
<a:ParamValue/>
</a:ParameterList>
<a:ParameterList>
<a:Paramname>newcallid</a:Paramname>
<a:ParamValue>160901-0083</a:ParamValue>
</a:ParameterList>
</CreateCallResult>
</CreateCallResponse>
</s:Body>
</s:Envelope>
下面是 XSL:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope"
xmlns:a="http://schemas.datacontract.org/2004/07/ServiceCallCreate"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:k="http://tempuri.org" exclude-result-prefixes="s k i a">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="utf-8" indent="yes" />
<xsl:template match="/">
<CreateCallResponse>
<ErrorCode>
<xsl:value-of select="s:Envelope/s:Body/k:CreateCallResponse/i:CreateCallResult/a:ParameterList/a:ParamValue" />
</ErrorCode>
</CreateCallResponse>
</xsl:template>
</xsl:stylesheet>
请大家帮我看看哪里做错了。
在样式表中,您没有使用输入中的 URI,因此将样式表中的 xmlns:k="http://tempuri.org"
更改为 xmlns:k="http://tempuri.org/"
,并将 xmlns:s="http://schemas.xmlsoap.org/soap/envelope"
更改为 xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
,然后更改<xsl:value-of select="s:Envelope/s:Body/k:CreateCallResponse/k:CreateCallResult/a:ParameterList/a:ParamValue" />
的路径。但是,我不确定您想要输入的哪个 ParamValue
。