当前位置: 动力学知识库 > 问答 > 编程问答 >

xforms - Orbeon - empty value as 0

问题描述:

I have many input fields in Orbeon in Form builder as war1, war2 , war3, and not all fields have to be filled. I want to make a sum of this fields (I can't make them repeatable because I want to reset it via web service), but when some of the fields are empty, the sum doesn't display. Using an initial value doesn't resolve the problem because I want to set values via a web service, and sometimes the values returned by the service are empty string.

网友答案:

Assuming your fields are named war1, war2, war3, use:

sum(($war1, $war2, $war3)[string() castable as xs:decimal], 0.0)

And for some background on this, see the blog post Formulas for summing values, done right, which is exactly about this topic. (The very fact that there is a blog entry about this tells you that this is rather subtle, which makes your question all the more justifiable.)

分享给朋友:
您可能感兴趣的文章:
随机阅读: