我正在寻找
输入 XML
<ClientInformation>
<FirstName>Steve</FirstName>
<LastName>Jobs</LastName>
<MiddleName/>
<DateOfBirth>09/18/2013</DateOfBirth>
<TaxIdentification>213465</TaxIdentification>
<ClientDetailPK>52385</ClientDetailPK>
<RoleTypeCT>OWN</RoleTypeCT>
<RoleTypeCT>IBE</RoleTypeCT>
<RoleTypeCT>Insured</RoleTypeCT>
</ClientInformation>
输出Xml
<SaveData>
<ClientInformation>
<FirstName>Steve</FirstName>
<LastName>Jobs</LastName>
<MiddleName/>
<DateOfBirth>09/18/2013</DateOfBirth>
<TaxIdentification>213465</TaxIdentification>
<ClientDetailPK>52385</ClientDetailPK>
<RoleTypeCT>OWN</RoleTypeCT>
</ClientInformation>
<ClientInformation>
<FirstName>Steve</FirstName>
<LastName>Jobs</LastName>
<MiddleName/>
<DateOfBirth>09/18/2013</DateOfBirth>
<TaxIdentification>213465</TaxIdentification>
<ClientDetailPK>52385</ClientDetailPK>
<RoleTypeCT>IBE</RoleTypeCT>
</ClientInformation>
<ClientInformation>
<FirstName>Steve</FirstName>
<LastName>Jobs</LastName>
<MiddleName/>
<DateOfBirth>09/18/2013</DateOfBirth>
<TaxIdentification>213465</TaxIdentification>
<ClientDetailPK>52385</ClientDetailPK>
<RoleTypeCT>Insured</RoleTypeCT>
</ClientInformation>
<SaveData>
所以我想复制所有ClientInformation
数据,除了RoleTypeCT
:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ClientInformation">
<SaveData>
<xsl:for-each select="RoleTypeCT">
<ClientInformation>
<xsl:apply-templates select="*[name()!='RoleTypeCT']"/>
<RoleTypeCT><xsl:value-of select="."/></RoleTypeCT>
</ClientInformation>
</xsl:for-each>
</SaveData>
</xsl:template>
</xsl:stylesheet>