无法使用 XSL 解析 SOAP 响应

Cannot Parse Through the SOAP response by using XSL

我是 XSLT 的新手,我想从 soap 响应生成一个 xml,由于命名空间问题,我无法解析 soap 响应并从标签中获取数据。

我的输入:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ProcessResponse xmlns="KeyIntgration">
        <ProcessResult xmlns="">
            <AccessId xmlns="KeyIntgration">paul</AccessId>
            <TransactionId xmlns="KeyIntgration">abcd</TransactionId>
            <Payload xmlns="KeyIntgration">
                <DeclaredValue>8.00</DeclaredValue>
            </Payload>
        </ProcessResult>
    </ProcessResponse>
</s:Body>
</s:Envelope>

这是我的 XSL 文件:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:k="KeyIntgration/"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   exclude-result-prefixes="s xsd xsi k">
<xsl:template match="/">
    <rate>
        <xsl:value-of
            select="s:Envelope/s:Body/k:ProcessResponse/k:ProcessResult/k:Payload/k:DeclaredValue/text()" />
    </rate>
</xsl:template>
</xsl:stylesheet>

我的输出是:

<?xml version="1.0" encoding="UTF-8"?>
  <rate/>

我的预期输出是:

<?xml version="1.0" encoding="UTF-8"?>
  <rate>8.00</rate>

提前致谢

  1. 修复 xmlns:k="KeyIntgration" 的命名空间(末尾没有 /)。
  2. ProcessResult 没有命名空间(因为 xmlns 为空 - <ProcessResult xmlns="">
  3. 在 Payload 和 DeclaredValue 之间还有一些元素。使用 //(或显式添加所有元素)。

尝试:

  <xsl:value-of
     select="s:Envelope/s:Body/k:ProcessResponse/ProcessResult/k:Payload//k:DeclaredValue/text()" />