接收遞歸這樣的XMLXSLT:轉變遞歸和重複的Xml
<ResponseXml>
<AccountData>
<AccountInformation>
<AccountNumber>123465</AccountNumber>
<BankCode>456</BankCode>
<OwnerInformation>
<FirstName>Himanshu</FirstName>
<LastName>Yadav</LastName>
</OwnerInformation>
<AccountInformation>
<AccountNumber>78910</AccountNumber>
<BankCode>123</BankCode>
<OwnerInformation>
<FirstName>My</FirstName>
<LastName>Wife</LastName>
</OwnerInformation>
</AccountInformation>
</AccountInformation>
</AccountData>
</ResponseXml>
它有一個傳統應用程序被格式化成:
<BillingInformation>
<AccountNumber>123465</AccountNumber>
<BankCode>456</BankCode>
</BillingInformation>
<ClientInfo>
<FirstName>Himanshu</FirstName>
<LastName>Yadav</LastName>
</ClientInfo>
<BillingInformation2>
<AccountNumber>78910</AccountNumber>
<BankCode>123</BankCode>
</BillingInformation2>
<ClientInfo>
<FirstName>My</FirstName>
<LastName>Wife</LastName>
</ClientInfo>
作爲新XSLT轉換我正在爲多個問題:
- 複製父項值時排除子元素。
- 然後複製新根元素下的排除子元素。
到目前爲止試過。
遞歸部分的部分解決方案。由於您使用的身份模板它不排除根元素<ResponseXml><AccountData>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="AccountInformation">
<BillingInformation>
<xsl:apply-templates select="*[name()!='AccountInformation']"/>
</BillingInformation>
<xsl:apply-templates select="AccountInformation"/>
</xsl:template>
<xsl:template match="AccountInformation/AccountInformation">
<BillingInformation2>
<xsl:apply-templates/>
</BillingInformation2>
</xsl:template>
請顯示您到目前爲止所嘗試的內容。 –
@JimGarrison我已經添加了我的部分解決方案來處理xml的遞歸部分。但我不知道排除每個孩子''元素。 –
您是否認爲我以正確的方式解決了這個問題? –