here is my input xml
<depositAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>12345678</number>
<status>Y</status>
<relationship>F-N</relationship>
<productCode>ICK</productCode>
<packageCode/>
<primaryIndicator>N</primaryIndicator>
<customer1DrivBen/>
<customer2Relationship>O-N</customer2Relationship>
<customer2DrivBen/>
<customer3Relationship/>
<customer3DrivBen/>
<customer3CifKey/>
<tierDetail>
<level>0</level>
<violationCounter>0</violationCounter>
<enrollmentDate>0</enrollmentDate>
</tierDetail>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>99999999</number>
<status>Y</status>
<relationship>F-N</relationship>
<productCode>ICK</productCode>
<packageCode>PDM</packageCode>
<primaryIndicator>N</primaryIndicator>
<customer1DrivBen/>
<customer2Relationship>O-N</customer2Relationship>
<customer2DrivBen/>
<customer3Relationship/>
<customer3DrivBen/>
<customer3CifKey/>
<tierDetail>
<level>0</level>
<violationCounter>0</violationCounter>
<enrollmentDate>0</enrollmentDate>
</tierDetail>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>12345678</number>
<status>N</status>
<productCode>KDB</productCode>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>85677833</number>
<status>N</status>
<productCode>KDB</productCode>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
</depositAccount>
Output should be as below
<depositAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>12345678</number>
<status>Y</status>
<relationship>F-N</relationship>
<productCode>ICK</productCode>
<packageCode/>
<primaryIndicator>N</primaryIndicator>
<customer1DrivBen/>
<customer2Relationship>O-N</customer2Relationship>
<customer2DrivBen/>
<customer3Relationship/>
<customer3DrivBen/>
<customer3CifKey/>
<tierDetail>
<level>0</level>
<violationCounter>0</violationCounter>
<enrollmentDate>0</enrollmentDate>
</tierDetail>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>99999999</number>
<status>Y</status>
<relationship>F-N</relationship>
<productCode>ICK</productCode>
<packageCode>PDM</packageCode>
<primaryIndicator>N</primaryIndicator>
<customer1DrivBen/>
<customer2Relationship>O-N</customer2Relationship>
<customer2DrivBen/>
<customer3Relationship/>
<customer3DrivBen/>
<customer3CifKey/>
<tierDetail>
<level>0</level>
<violationCounter>0</violationCounter>
<enrollmentDate>0</enrollmentDate>
</tierDetail>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>85677833</number>
<status>N</status>
<productCode>KDB</productCode>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
</depositAccount>
I have the below code
<xsl:for-each-group select="$depositAccount/EligibleDepAccount[status = 'Y']" group-by="number">
<xsl:if test="count(current-group()) = 2 and $depositAccount/EligibleDepAccount[status = 'Y']">
<xsl:copy-of select="."/>
</xsl:if>
<xsl:if test="not(current-group()[2])">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each-group>
just doesn't seem to work, output coming back is below which is wrong, what is wrong with the above the xslt code ? I think there are 2 if conditions which is passing though, how can i break if the first test condition is met. please help
<depositAccount>
<EligibleDepAccount>
<type>DDA</type>
<market>050</market>
<number>12345678</number>
<status>Y</status>
<relationship>F-N</relationship>
<productCode>ICK</productCode>
<packageCode/>
<primaryIndicator>N</primaryIndicator>
<customer1DrivBen/>
<customer2Relationship>O-N</customer2Relationship>
<customer2DrivBen/>
<customer3Relationship/>
<customer3DrivBen/>
<customer3CifKey/>
<tierDetail>
<level>0</level>
<violationCounter>0</violationCounter>
<enrollmentDate>0</enrollmentDate>
</tierDetail>
<TIEligible>false</TIEligible>
</EligibleDepAccount>
</depositAccount>
If you want to group by
number
independent of thestatus
but then want to output the first item in each group withstatus = 'Y'
or if there are no then the first item you can achieve that as follows:Given the input
we then get the output
You are outputting the same thing in both branches of the conditional, which suggests you might be thinking that select="." will output the current group? Perhaps you want
Within
xsl:for-each-group
, "." refers to the first item in the current group.