Orbeon Runner - 计算值

时间:2013-04-19 12:36:45

标签: orbeon

我制作了一个带有一些文本输出控件的表单,这些控件的某些其他控件的计算值也有计算值。问题是,在测试模式(来自构建器)中,这些控件正常工作。在跑步者中,这些控件始终为0(空)。保存文档并再次打开后,值正确,但不刷新。

这是我的实例:

<xforms:instance id="fr-form-instance">
    <form>
        <section-1>
            <first>
                <first_amount/>
                <first_percent/>
                <first_total/>
            </first>
            <second>
                <second_amount/>
                <second_percent/>
                <second_total/>
            </second>
            <third>
                <third_amount/>
                <third_percent/>
                <third_total/>
            </third>
            <total/>
            <average/>
        </section-1>
    </form>
</xforms:instance>

我的绑定:

<xforms:bind xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" id="fr-form-binds"
             nodeset="instance('fr-form-instance')">
    <xforms:bind id="section-1-bind" name="section-1" ref="section-1">
        <xf:bind name="first" id="first-bind" ref="first">
            <xf:bind name="first_amount" id="first_amount-bind" ref="first_amount"
                     type="xf:decimal"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="first_percent"
                     id="first_percent-bind"
                     ref="first_percent"
                     type="xf:decimal"
                     constraint="./text()&gt;=0 or string-length(./text())=0"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="first_total"
                     id="first_total-bind"
                     ref="first_total"
                     calculate="(../first_amount/text() * ../first_percent/text()) div 100"
                     type="xf:decimal"/>
        </xf:bind>
        <xf:bind name="second" id="second-bind" ref="second">
            <xf:bind name="second_amount" id="second_amount-bind" ref="second_amount"
                     type="xf:decimal"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="second_percent"
                     id="second_percent-bind"
                     ref="second_percent"
                     type="xf:decimal"
                     constraint="./text()&gt;=0 or string-length(./text())=0"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="second_total"
                     id="second_total-bind"
                     ref="second_total"
                     calculate="(../second_amount/text() * ../second_percent/text()) div 100"
                     type="xf:decimal"/>
        </xf:bind>
        <xf:bind name="third" id="third-bind" ref="third">
            <xf:bind name="third_amount" id="third_amount-bind" ref="third_amount"
                     type="xf:decimal"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="third_percent"
                     id="third_percent-bind"
                     ref="third_percent"
                     type="xf:decimal"
                     constraint="./text()&gt;=0 or string-length(./text())=0"/>
            <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="third_total"
                     id="third_total-bind"
                     ref="third_total"
                     calculate="(../third_amount/text() * ../third_percent/text()) div 100"
                     type="xf:decimal"/>
        </xf:bind>
        <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="total"
                 id="total-bind"
                 ref="total"
                 calculate="sum(instance('fr-form-instance')/section-1/first/first_total/text()) + sum(instance('fr-form-instance')/section-1/second/second_total/text()) + sum(instance('fr-form-instance')/section-1/third/third_total/text())"
                 type="xf:decimal"/>
        <xf:bind xmlns:fb="http://orbeon.org/oxf/xml/form-builder" name="average"
                 id="average-bind"
                 ref="average"
                 type="xf:decimal"
                 calculate="instance('fr-form-instance')/section-1/total/text() div (count(instance('fr-form-instance')/section-1/first) + count(instance('fr-form-instance')/section-1/second) + count(instance('fr-form-instance')/section-1/third))"/>
    </xforms:bind>
</xforms:bind>

1 个答案:

答案 0 :(得分:1)

在测试模式和部署表单时,这似乎对我提供了所提供的表单(参见屏幕截图)。我使用的是Orbeon Forms 4.1。

并不重要,但这里有一些关于XPath表达式的注释:

    在XPath中几乎不需要
  • text(),您可以删除表达式中/text()的所有此类事件
  • 而不是&gt;=,您可以使用更具可读性的ge运算符

screenshot