我正在尝试将数字四舍五入到2dp并且我正在努力
我正在尝试使用十进制字符串方法
这就是我所拥有的
<xf:bind nodeset="/stuff/price"
calculate = "if(boolean-from-string(/stuff/amountOff),
((/stuff/items) * (/stuff/duration) * 0.8),/stuff/items* /stuff/duration)" />
这就是我试过的
<xf:bind
nodeset="/stuff/price"
calculate = "decimal-string(if(boolean-from-string(/stuff/amountOff),
((/stuff/items) * (/stuff/duration) * 0.8),/stuff/items* /stuff/duration)" , 2)/>
答案 0 :(得分:1)
标准XForms不支持decimal-string()
函数,您使用的是哪种实现?可以看到可用标准函数的完整列表here(请注意它也引用了XPath 1.0)。
根据您选择的XForms处理器,您可以使用扩展功能(例如,formsPlayer从MSXML公开format-number()
功能),或者您可能需要定义自己的功能自定义扩展(例如在javascript中)否则。