如果其他条件似乎没有在 for-each-group 下正确评估 [英] If else condition doesn't seem to evaluate right under for-each-group
本文介绍了如果其他条件似乎没有在 for-each-group 下正确评估的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的输入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>
输出应该如下
<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>
我有以下代码
<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>
似乎不起作用,返回的输出低于哪个错误,上面的 xslt 代码有什么问题?我认为有 2 个 if 条件正在通过,如果满足第一个测试条件,我该如何中断.请帮忙
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>
推荐答案
您在条件的两个分支中输出相同的内容,这表明您可能认为 select="."会输出当前组吗?也许你想要
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
<xsl:copy-of select="current-group()"/>
在 xsl:for-each-group
中,."指当前组中的第一项.
Within xsl:for-each-group
, "." refers to the first item in the current group.
这篇关于如果其他条件似乎没有在 for-each-group 下正确评估的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文