需要帮助将SOAP消息转换为XML: 元素" externalID"可以多次出现,因此基于" externalID"这个元素需要生成"细节"输出XML中的标记。
需要一些代码示例才能将此SOAP消息转换为所需的输出XML 输入SOAP消息:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mem="http://example.com/vc/types/attachments">
<soapenv:Header/>
<soapenv:Body>
<mem:payRequest>
<payload>
<uuid>?</uuid>
<umi>?</umi>
<externalID>
<externalLineID></externalLineID>
<groupNo>?</groupNo>
<payeeCd>dfsdfsfd</payeeCd>
<paymntAmt>?</paymntAmt>
<acctCd>dfafa</acctCd>
<transID>fasf</transID>
<errCD>?</errCD>
<errMessage>?</errMessage>
</externalID>
<externalID>
<externalLineID>?</externalLineID>
<groupNo>?</groupNo>
<payeeCd>dfsdfsfd</payeeCd>
<paymntAmt>?</paymntAmt>
<acctCd>dfafa</acctCd>
<transID>fasf</transID>
<errCD>?</errCD>
<errMessage>?</errMessage>
</externalID>
<errCD>?</errCD>
<errMessage>?</errMe`enter code here`ssage>
</payload>
</mem:payRequest>
</soapenv:Body>
</soapenv:Envelope>
==============
所需的输出XML:
<payRequest>
<Detail>
<uuid>?</uuid>
<umd>?</umd>
<claimNumber></claimNumber>
<claimLineNumber>?</claimLineNumber>
<dd>1</dd>
<claimStatus></claimStatus>
<clientNumber></clientNumber>
<payMode>Other</payMode>
<paymentAmount></paymentAmount>
<accountCode></accountCode>
<transactionId></transactionId>
<errorCode></errorCode>
<returnCode></returnCode>
</Detail>
<Detail>
<uuid>?</uuid>
<umd>?</umd>
<claimNumber></claimNumber>
<claimLineNumber>?</claimLineNumber>
<dd>1</dd>
<claimStatus></claimStatus>
<clientNumber></clientNumber>
<payMode>Other</payMode>
<paymentAmount></paymentAmount>
<accountCode></accountCode>
<transactionId></transactionId>
<errorCode></errorCode>
<returnCode></returnCode>
</Detail>
</payRequest>
答案 0 :(得分:0)
我建议您按照以下方式进行尝试:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<payRequest>
<xsl:for-each select="//externalID">
<Detail>
<uuid>
<xsl:value-of select="../uuid"/>
</uuid>
<umd>
<xsl:value-of select="../umi"/>
</umd>
<claimNumber>
<xsl:value-of select="XYZ"/>
</claimNumber>
<claimLineNumber>
<xsl:value-of select="externalLineID"/>
</claimLineNumber>
<dd>
<xsl:value-of select="XYZ"/>
</dd>
<claimStatus>
<xsl:value-of select="XYZ"/>
</claimStatus>
<clientNumber>
<xsl:value-of select="XYZ"/>
</clientNumber>
<payMode>
<xsl:value-of select="XYZ"/>
</payMode>
<paymentAmount>
<xsl:value-of select="paymntAmt"/>
</paymentAmount>
<accountCode>
<xsl:value-of select="XYZ"/>
</accountCode>
<transactionId>
<xsl:value-of select="transID"/>
</transactionId>
<errorCode>
<xsl:value-of select="errCD"/>
</errorCode>
<returnCode>
<xsl:value-of select="XYZ"/>
</returnCode>
</Detail>
</xsl:for-each>
</payRequest>
</xsl:template>
</xsl:stylesheet>
您没有提供有关哪些源节点应该为结果提供数据的任何信息。我试图猜测一些,并使用XYZ
作为其他人的占位符。
注意:您永远不必使用像*[local-name()='externalID']
这样的黑客。