Orbeon XML环境下布尔值转数值 公式计算仍返回布尔类型如何解决
Orbeon XML环境布尔值转数值类型解决方案
你当前返回布尔值的核心原因是公式中使用了逻辑运算符or:该运算符的返回值固定为布尔类型,只要两侧运算结果存在大于0的数值,就会返回true,和你调用的round数值运算函数无关。
你可以根据实际需求选择对应解决方案:
- 若你的需求是取两个计算结果的较大值,替换
or为max()函数即可返回数值类型结果:
公式示例:max(round(seconds($total-time-calculation-mental) div 60), round(seconds($control-2) div 60)) - 若你的需求是将布尔判断结果转为数值(true转1、false转0),用
number()函数包裹整个逻辑表达式即可:
公式示例:number(round(seconds($total-time-calculation-mental) div 60 ) or round(seconds($control-2) div 60)) - 若你的需求是对两个计算结果做求和运算,直接把
or替换为算术运算符+即可:
公式示例:round(seconds($total-time-calculation-mental) div 60 ) + round(seconds($control-2) div 60)
内容的提问来源于stack exchange,提问作者Eva
相关产品推荐
相关产品推荐

