开发者

and and or condition in single xml statement

开发者 https://www.devze.com 2023-01-04 09:42 出处:网络
I want to construct a statement containing and and multiple or expressions in xml li开发者_开发问答ke

I want to construct a statement containing and and multiple or expressions in xml li开发者_开发问答ke

<xsl:choose>
  <xsl:when test="VAR1 and VAR1/text() != 'A' | 'B' | 'C'">
   <xsl:value-of select="$data"/>
  </xsl:when>
  <xsl:otherwise>0.0</xsl:otherwise>
</xsl:choose>

but its nt working...


One solution, which avoids multiple comparisons is:

VAR1 and VAR1/text()[not(contains('A+B+C', .))]

where the + string is guaranteed not to be contained in VAR1/text() (if "+" doesn't satisfy this requirement, substitute "+" with a string that does)

Do note that there is a likely logical error in the question:

x != 'A' or x != 'B' or x != 'C'

is always true

Most probably you wanted:

x != 'A' and x != 'B' and x != 'C'

0

精彩评论

暂无评论...
验证码 换一张
取 消