条件 AND OR 两个不同的值
我有两个不同变量的 AND 和 OR 串联。我尝试了以下方法:
<xsl:if test="$countryCode = '104'
and
(transactionType != 'Allowance'
or
revenueCenter != '1100')">
但这不起作用。是否可以进行条件测试,或者我是否必须像这样拆分它:
<xsl:if test="$countryCode='104'>
在第二个元素中,我这样做:
<xsl:if transactionType!='Allowance' or revenueCenter!='1100'>
I have a concatenation of AND and OR for 2 different variables. And I tried the following:
<xsl:if test="$countryCode = '104'
and
(transactionType != 'Allowance'
or
revenueCenter != '1100')">
But that does not work. Is it possible to do a conditional test or do I have to split it up like this:
<xsl:if test="$countryCode='104'>
and in a second element I do:
<xsl:if transactionType!='Allowance' or revenueCenter!='1100'>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XPath 表达式:
语法正确。
我们无法谈论任何有关语义的内容,因为没有提供 XML 文档,也没有解释表达式必须选择什么。
像往常一样,建议不要使用
!=
运算符,除非确实必要——当参数之一是节点集(或序列或XPath 2.0 中的节点集)与大多数人的期望相差甚远。最好使用函数
not()
: 而不是!=
:并且这可以进一步重构为更短且等效的:
The XPath expression:
is syntactically correct.
We cannot say anything about the semantics, as no XML document is provided and there is no explanation what the expression must select.
As usual, there is the recommendation not to ose the
!=
operator, unless really necessary -- its use when one of the arguments is a node-set (or sequence or node-set in XPath 2.0) is very far from what most people expect.Instead of
!=
better use the functionnot()
:and this can further be refactored to the shorter and equivalent: