geeting uplicated value in xsl:for tag while xml transformation



I have the below xml



<?xml version="1.0" encoding="UTF-8"?>
<Report xmlns:fpml="http://ift.tt/1gVfJXZ" xmlns="http://ift.tt/1z9w9pO" name="CB202 Full Inventory Report">
<reportNameGrp>
<CM>
<acctTypGrp name="A9">
<ProductType name="Swap">
</ProductType>
</acctTypGrp>
<acctTypGrp name="P">
<ProductType name="Swap">
</ProductType>
<ProductType name="FRA">
</ProductType>
</acctTypGrp>
</CM>
</reportNameGrp>
</Report>


and for which i have written the xsl for xml transformation , I have written the xslt below



<xsl:stylesheet version="1.0" xmlns:fpml="http://ift.tt/1gVfJXZ"
xmlns:xsl="http://ift.tt/tCZ8VR" xmlns:eur="http://ift.tt/1z9w9pO"
xmlns:java="http://ift.tt/Y48VNG" exclude-result-prefixes="java">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>


<!-- Main Template starts from here -->
<xsl:template match="/eur:Report">
<Eurexflows>
<xsl:call-template name="EurexreportNameGrp_block">
<xsl:with-param name="CMaccounttypeGroup" select="/eur:Report/eur:reportNameGrp/eur:CM/eur:acctTypGrp" />
</xsl:call-template>
</Eurexflows>
</xsl:template>

<!-- Main tempalte ends -->

<!-- sub templates starts -->
<xsl:template name="EurexreportNameGrp_block">
<xsl:param name="CMaccounttypeGroup" />
<xsl:for-each select="$CMaccounttypeGroup">
<EurexMessageObject>
<name>
<xsl:value-of select="@name" />
</name>
<ProductType>
<xsl:value-of select="$CMaccounttypeGroup/eur:ProductType/@name" />
<xsl:call-template name="generateData">
<xsl:with-param name="data" select="."/>
</xsl:call-template>
</ProductType>
</EurexMessageObject>
</xsl:for-each>
</xsl:template>
<xsl:template name="generateData">
<xsl:param name="data" />
<xsl:for-each select="$data/eur:ProductType">
<xsl:value-of select="./@name" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


but upon xsl transformation I am getting the xml in below format



<Eurexflows xmlns:eur="http://ift.tt/1z9w9pO"
xmlns:fpml="http://ift.tt/1gVfJXZ">
<EurexMessageObject>
<name>A9</name>
<ProductType>SwapSwap</ProductType>
</EurexMessageObject>
<EurexMessageObject>
<name>P</name>
<ProductType>SwapSwapFRA</ProductType>
</EurexMessageObject>
</Eurexflows>


but I want xml in this format,



<Eurexflows xmlns:eur="http://ift.tt/1z9w9pO"
xmlns:fpml="http://ift.tt/1gVfJXZ">
<EurexMessageObject>
<name>A9</name>
<ProductType>Swap</ProductType>
</EurexMessageObject>
<EurexMessageObject>
<name>P</name>
<ProductType>Swap</ProductType>
</EurexMessageObject>
<EurexMessageObject>
<name>P</name>
<ProductType>FRA</ProductType>
</EurexMessageObject>
</Eurexflows>


please avise how to achieve the above xml after transformation and also please advise what necessary changes i need to do in xsl specially in my generateData template..


No comments:

Post a Comment