在我的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>
在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, '|'))