入力 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>