需要在xslt 1.0中识别没有条件参数的重复项

时间:2013-11-17 13:50:50

标签: xslt xslt-2.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,然后拉出该对象。我使用下面的代码

<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'似乎根本不起作用。

1 个答案:

答案 0 :(得分:0)

您使用for-each-group,但将问题标记为xslt-1.0,这是没有意义的。

假设您认为XSLT 2.0处理器只是想要

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