How to add multiple test conditions in 'test' attribute expression of tag

后端 未结 2 1984
轻奢々
轻奢々 2021-01-01 10:57

Is there any possibility to include multiple conditions in \'test\' attribute expression in tag of XSLT like



        
相关标签:
2条回答
  • 2021-01-01 11:04
    <xsl:if test="$var='ab' | $var='bc' | $var='ca' ">
    

    This is wrong -- you are using the XPath union operator | on boolean values.

    Solution: use the XPath or operator:

    <xsl:if test="$var='ab' or $var='bc' or $var='ca' ">
    

    The above XPath expression (the value of the test attribute) can be optimized, so that only one comparison is made and no or is necessary:

    <xsl:if test="contains('|ab|bc|ca|', concat('|', $var, '|'))">
    
    0 讨论(0)
  • 2021-01-01 11:04

    In XSLT 2.0 or above, you can test against a sequence of strings:

    <xsl:if test="$var=('ab','bc','ca')">...</xsl:if>
    
    0 讨论(0)
提交回复
热议问题