给定 XSL 'If' 语句:
<xsl:if test="a = 'some value' and b = 'another value'">
如
a
不等于 'some value'
, 是 b
的值还在检查吗? (好像第一个测试是 false
, and
的唯一结果是 false
。)这就是像 C# 这样的语言所做的 - 我想知道 XSL 中是否也是如此。它是否取决于引擎/解析器?
最佳答案
是的,它被称为延迟评估或短路,并且 xsl 支持它。见:http://www.w3.org/TR/xpath#booleans
An and expression is evaluated by evaluating each operand and converting its value to a boolean as if by a call to the boolean function. The result is true if both values are true and false otherwise. The right operand is not evaluated if the left operand evaluates to false.
关于xslt - XSL - 评估条件表达式 "shortcut"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1410057/