接收递归这样的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的递归部分。但我不知道排除每个孩子''元素。 –
您是否认为我以正确的方式解决了这个问题? –