1

在我的 xslt 代码中,我需要有如下条件

<xsl:when test="$CreditCardType ='SWITCH' 
                and 
                ($ccLength =16 
                 or $ccLength =18 
                 or $ccLength =19)">
  <xsl:value-of select="true()"/>
</xsl:when>

<xsl:when test="$firstFourDigits ='5018' 
                or $firstFourDigits ='5020' 
                or $firstFourDigits ='5038' 
                or $firstFourDigits ='6304' 
                or $firstFourDigits ='6759' 
                or $firstFourDigits ='6761' 
                or $firstFourDigits ='6763'">
  <xsl:value-of select="'MAESTRO'"/>
</xsl:when>

无论如何,我可以避免那些多重或条件,简化代码,如下所示?

<xsl:when test="$firstFourDigits ='5018' | '5020' | '5038' | '6304' | '6759' | '6761'| '6763'">
                        <xsl:value-of select="'MAESTRO'"/>
                    </xsl:when>
4

1 回答 1

2

在 xslt 2.0 中,你可以做到这一点

test="$firstFourDigits = 
      ('5018', '5020', '5038', '6304', '6759', '6761', '6763')"

在 xslt 1.0 中,您可能可以使用concat()contains()运行

contains(concat('5018|', '5020|', '5038|', 
         '6304|', '6759|', '6761|', '6763|'), 
          concat($firstFourDigits, '|'))
于 2013-08-14T19:29:03.237 回答