removing duplicate in xmlnotdisplaying correct result
<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" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="kMapping" match="Registration" use="Country"/>
<xsl:template match="@* | node()" name="Copy">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Registration[generate-id() = generate-id(key('kMapping', Country)[1])]">
<xsl:call-template name="Copy"/>
</xsl:template>
<xsl:template match="Registration"/>
</xsl:stylesheet>
XML Code Input file
=================
<FundsXML> <Funds> <Fund> <Name>Fund11111 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> </KeyFacts> </FundFacts> <Name>Fund22222 </Name> <SecurityCodes> <CountrySecurityCode> <CountryCode>DE</CountryCode> </CountrySecurityCode> </SecurityCodes> <FundFacts> <KeyFacts> <Registration> <Country>AE</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>PT</Country> </Registration> </KeyFacts> </FundFacts> </Fund> </Funds> </FundsXML>
Desired output
Need country code to be displayed once per fund11111 and fund22222
<FundsXML> <Funds> <Fund> <Name>Fund11111 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> </KeyFacts> </FundFacts> <Name>Fund22222 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AE</Country> </Registration> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> <Registration> <Country>PT</Country> </Registration> </KeyFacts> </FundFacts> </Fund> </Funds> </FundsXML>
The code is displayed singlecountry record for first fund only and removing country value records which are present in Fund22222
Output displayed by above XSLT
==============================
<FundsXML> <Funds> <Fund> <Name>Fund11111 </Name> <FundFacts> <KeyFacts> <Registration> <Country>AT</Country> </Registration> <Registration> <Country>BE</Country> </Registration> </KeyFacts> </FundFacts> <Name>Fund22222 </Name> <FundFacts> <KeyFacts> <Registration> <Country>PT</Country> </Registration> </KeyFacts> </FundFacts> </Fund> </Funds> </FundsXML>
Any help will be much appreciated
|