需要在 xslt1.0 中使用条件参数识别重复项 [英] need to identify duplicates with a condtional param in xslt1.0

查看:22
本文介绍了需要在 xslt1.0 中使用条件参数识别重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的输入

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

我需要找出相同的帐号对象并检查状态是否为 Y ,然后拉出该对象.我使用了下面的代码

I need to find out same account number objects and check if the status is Y , then pull that object. I used the below code

<xsl:for-each-group select="$depositAccount/EligibleDepAccount" group-by="number">  
  <xsl:variable name="stat" select="$depositAccount/EligibleDepAccount/status/text()" />
  <xsl:if test="count(current-group()) = 2">
    <xsl:copy-of select="current-group()[1]"/>              
  </xsl:if>
  <xsl:if test="count(current-group()) = 1 and $stat = 'Y'">
    <xsl:copy-of select="."/>               
  </xsl:if>
</xsl:for-each-group>

在上面的代码中,test="count(current-group()) = 1 and $stat = 'Y' 似乎根本不起作用.

In the above code, test="count(current-group()) = 1 and $stat = 'Y' doesn't seem to work at all.

推荐答案

您使用 for-each-group 但将问题标记为 xslt-1.0,这不有道理.

You use for-each-group but tag the question as xslt-1.0, that does not make sense.

假设使用 XSLT 2.0 处理器,我认为您只是想要

Assuming an XSLT 2.0 processor I think you simply want

<xsl:for-each-group select="$depositAccount/EligibleDepAccount[status = 'Y']" group-by="number"> 
  <xsl:copy-of select="."/>
</xsl:for-each-group>

这篇关于需要在 xslt1.0 中使用条件参数识别重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆