如何在<xforms:repeat>中找到<fr:currency>字段的总和和最大值?</xforms:repeat> </fr:currency>

时间:2012-02-01 13:36:37

标签: sum max repeat orbeon xforms

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:sql="http://orbeon.org/oxf/xml/sql"
    xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
    xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:saxon="http://saxon.sf.net/"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:oxf="http://www.orbeon.com/oxf/processors"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
    xmlns:exforms="http://www.exforms.org/exf/1-0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
    xmlns:f="http://orbeon.org/oxf/xml/formatting"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exf="http://www.exforms.org/exf/1-0"
    xmlns:date="http://exslt.org/dates-and-times">

    <xhtml:head>


        <xforms:model id="model">


        <xforms:instance id="test">
            <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <add>
                    <yes></yes>
                </add>
            </form>
        </xforms:instance>  

        <xforms:instance id="duplicate-section">
                <form>
                <add>
                    <yes></yes>
                </add>
                </form>
        </xforms:instance>

                <xforms:bind id="yes" nodeset="instance('test')/add/yes" />

        </xforms:model>
    </xhtml:head>

    <xhtml:body>
        <table>
            <tr>
                <td>
                    <xforms:trigger incremental="true">
                        <xforms:label>Add</xforms:label> 
                        <xforms:insert ev:event="DOMActivate" context="instance('test')" origin="instance('duplicate-section')/add"/>
                    </xforms:trigger>
                </td>
            </tr>
            <xforms:repeat nodeset="instance('test')/add" id="add-repeat" startindex="1">
            <tr>
            <td><xforms:output ref="position()"/></td>
                <td>
                    <fr:currency ref="yes" incremental="true">
                    </fr:currency>
                </td>
            </tr>
        </xforms:repeat>            
        </table>
    </xhtml:body>
</xhtml:html>

考虑一下,我点击添加按钮5次,然后在5个文本框中输入值。我想找到输入的这5个值的总和,我想找到这5个值的最大值。我怎样才能做到这一点?我只想显示总和和最大值。

1 个答案:

答案 0 :(得分:1)

对于Sum,您可以输出此xpath表达式:

<xforms:output value="sum(instance('test')/add/yes)" />

对于Max,请使用:

<xforms:output value="max(instance('test')/add/yes)" />