1

我正在尝试创建一个在 Orbeon 服务器中运行的具有嵌套重复的表单。这个想法是让一些元素可以重复,而第一个元素中的其他元素也可以重复。即用于插入个人信息的块(重复的几个人),对于每个人,我们可以添加几个电话号码(也是重复的)。

我还没有找到太多关于如何做到这一点的信息,我想我可以创建这个:其他 StackOverflow 问题(但这个例子对我也不起作用,即使评论中公开了更正)。

为了测试,我创建了下一个表单:

<xh:html xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xpl="java:org.orbeon.oxf.pipeline.api.FunctionLibrary"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
    <xh:title>LoopInLoop</xh:title>
    <xf:model id="fr-form-model" xxf:expose-xpath-types="true">
        <xf:instance id="fr-form-metadata" xxf:readonly="true">
            <metadata>
                <application-name>DHszw</application-name>
                <form-name>LoopInLoop</form-name>
                <title xml:lang="en">LoopInLoop</title>
                <description xml:lang="en">Description of the form.</description>
            </metadata>
        </xf:instance>
        <xf:instance id="fr-form-instance">
            <form>
                <category-1>
                    <subcategory-1-1/>
                    <loop-group-0>
                        <loop-0>
                            <loop-group-0-0>
                                <loop-0-0>
                                <element-1-1-1/>
                                <element-1-1-2/>
                                </loop-0-0>
                            </loop-group-0-0>
                            <element-1-1-3/>
                            <element-1-1-4/>
                        </loop-0>
                    </loop-group-0>
                    <element-1-1-5/>
                </category-1>
            </form>
        </xf:instance>
        <xf:bind id="fr-form-binds"
            ref="instance('fr-form-instance')" xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel">
            <xf:bind id="category-1-bind" name="category-1" ref="category-1">
                <xf:bind id="subcategory-1-1-bind"
                    name="subcategory-1-1" ref="subcategory-1-1"/>
                <xf:bind id="group-loop-0-bind"
                    name="group-loop-0-bind" ref="loop-group-0">
                    <xf:bind id="loop-0-bind" name="loop-0" ref="loop-0">
                        <xf:bind id="group-loop-0-0-bind"
                            name="group-loop-0-0-bind" ref="loop-group-0-0">
                            <xf:bind id="loop-0-0-bind"
                                name="loop-0-0" ref="loop-0-0">
                                <xf:bind id="element-1-1-1-bind"
                                name="element-1-1-1" ref="element-1-1-1"/>
                                <xf:bind id="element-1-1-2-bind"
                                name="element-1-1-2" ref="element-1-1-2"/>
                            </xf:bind>
                        </xf:bind>
                        <xf:bind id="element-1-1-3-bind"
                            name="element-1-1-3" ref="element-1-1-3" relevant="(../$element-1-1-2='no' )"/>
                        <xf:bind id="element-1-1-4-bind"
                            name="element-1-1-4" ref="element-1-1-4" relevant="(../$element-1-1-2='no' )"/>
                    </xf:bind>
                </xf:bind>
                <xf:bind id="element-1-1-5-bind"
                    name="element-1-1-5" ref="element-1-1-5" relevant="($element-1-1-4='no' )"/>
            </xf:bind>
        </xf:bind>
        <xf:instance id="fr-form-attachments">
            <attachments>
                <css filename="" mediatype="text/css" size=""/>
                <pdf filename="" mediatype="application/pdf" size=""/>
            </attachments>
        </xf:instance>
        <xf:instance id="fr-form-resources" xxf:readonly="false">
            <resources>
                <resource xml:lang="en">
                    <category-1>
                        <label><![CDATA[new category]]></label>
                    </category-1>
                    <subcategory-1-1>
                        <label><![CDATA[<b>new sub-category</b><hr>]]></label>
                        <hint/>
                        <alert><![CDATA[]]></alert>
                    </subcategory-1-1>
                    <element-1-1-1>
                        <label><![CDATA[Add something]]></label>
                        <hint><![CDATA[]]></hint>
                        <alert/>
                    </element-1-1-1>
                    <element-1-1-2>
                        <label><![CDATA[More Loops?]]></label>
                        <hint><![CDATA[]]></hint>
                        <alert/>
                        <item>
                            <label><![CDATA[yes]]></label>
                            <value><![CDATA[yes]]></value>
                        </item>
                        <item>
                            <label><![CDATA[no]]></label>
                            <value><![CDATA[no]]></value>
                        </item>
                    </element-1-1-2>
                    <element-1-1-3>
                        <label><![CDATA[AddOtherThing]]></label>
                        <hint><![CDATA[]]></hint>
                        <alert/>
                    </element-1-1-3>
                    <element-1-1-4>
                        <label><![CDATA[MorewLoop2]]></label>
                        <hint><![CDATA[]]></hint>
                        <alert/>
                        <item>
                            <label><![CDATA[yes]]></label>
                            <value><![CDATA[yes]]></value>
                        </item>
                        <item>
                            <label><![CDATA[no]]></label>
                            <value><![CDATA[no]]></value>
                        </item>
                    </element-1-1-4>
                    <element-1-1-5>
                        <label><![CDATA[group.End]]></label>
                        <hint><![CDATA[]]></hint>
                        <alert/>
                    </element-1-1-5>
                </resource>
            </resources>
        </xf:instance>
        <xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
            <response/>
        </xf:instance>
       <xf:instance id="loop-0-template" xxf:readonly="true">
            <loop-0>
                <element-1-1-1/>
                <element-1-1-2/>
                <loop-0-0/>                    
            </loop-0>
        </xf:instance>
        <xf:instance id="loop-0-0-template" xxf:readonly="true">
            <loop-0-0>
                <element-1-1-3/>
                <element-1-1-4/>
            </loop-0-0>
        </xf:instance>
    </xf:model>
</xh:head>
<xh:body>
    <fr:view>
        <fr:body xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel"
            xmlns:oxf="http://www.orbeon.com/oxf/processors"
            xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xbl="http://www.w3.org/ns/xbl">
            <fr:section bind="category-1-bind" id="category-1-control">
                <xf:label ref="$form-resources/category-1/label"/>
                <xh:tr>
                    <xh:td>
                        <xf:output bind="subcategory-1-1-bind" id="subcategory-1-1-control">
                            <xf:label mediatype="text/html" ref="$form-resources/subcategory-1-1/label"/>
                            <xf:hint ref="$form-resources/subcategory-1-1/hint"/>
                            <xf:alert ref="$fr-resources/detail/labels/alert"/>
                        </xf:output>
                    </xh:td>
                </xh:tr>
                <xf:group bind="group-loop-0-bind" id="group-loop-0-control">
                    <fr:grid bind="loop-0-bind" id="loop-0-control"
                        max="10" min="1"
                        origin="instance('loop-0-template')" repeat="true">
                        <xf:group bind="group-loop-0-0-bind" id="group-loop-0-0-control">
                            <fr:grid bind="loop-0-0-bind"
                                id="loop-0-0-control" max="10"
                                min="1"
                                origin="instance('loop-0-0-template')" repeat="true">
                                <xh:tr>
                                <xh:td>
                                <xf:input
                                bind="element-1-1-1-bind" id="element-1-1-1-control">
                                <xf:label ref="$form-resources/element-1-1-1/label"/>
                                <xf:hint ref="$form-resources/element-1-1-1/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                </xf:input>
                                </xh:td>
                                </xh:tr>
                                <xh:tr>
                                <xh:td>
                                <xf:select1
                                appearance="full"
                                bind="element-1-1-2-bind" id="element-1-1-2-control">
                                <xf:label ref="$form-resources/element-1-1-2/label"/>
                                <xf:hint ref="$form-resources/element-1-1-2/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                <xf:itemset ref="$form-resources/element-1-1-2/item">
                                <xf:label ref="label"/>
                                <xf:value ref="value"/>
                                </xf:itemset>
                                </xf:select1>
                                </xh:td>
                                </xh:tr>
                            </fr:grid>
                        </xf:group>
                        <xh:tr>
                            <xh:td>
                                <xf:input bind="element-1-1-3-bind" id="element-1-1-3-control">
                                <xf:label ref="$form-resources/element-1-1-3/label"/>
                                <xf:hint ref="$form-resources/element-1-1-3/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                </xf:input>
                            </xh:td>
                        </xh:tr>
                        <xh:tr>
                            <xh:td>
                                <xf:select1 appearance="full"
                                bind="element-1-1-4-bind" id="element-1-1-4-control">
                                <xf:label ref="$form-resources/element-1-1-4/label"/>
                                <xf:hint ref="$form-resources/element-1-1-4/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                <xf:itemset ref="$form-resources/element-1-1-4/item">
                                <xf:label ref="label"/>
                                <xf:value ref="value"/>
                                </xf:itemset>
                                </xf:select1>
                            </xh:td>
                        </xh:tr>
                    </fr:grid>
                </xf:group>
                <fr:grid>
                    <xh:tr>
                        <xh:td>
                            <xf:output bind="element-1-1-5-bind" id="element-1-1-5-control">
                                <xf:label ref="$form-resources/element-1-1-5/label"/>
                                <xf:hint ref="$form-resources/element-1-1-5/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>
                            </xf:output>
                        </xh:td>
                    </xh:tr>
                </fr:grid>
            </fr:section>
        </fr:body>
    </fr:view>
</xh:body>
</xh:html>

但只显示“嵌套重复”而不是“外部”重复。

问题是:它不是在 Orbeon 中实现的吗?它需要特定的语法吗?或者有什么我看不到的错误?

我正在使用 Orbeon 4.3.0.1.201308150213-CE。

编辑: 我已经更改了循环的“模板”部分并进行了一些更正。

4

1 回答 1

1

目前不支持嵌套<fr:grid>。但是我们计划很快实现对嵌套部分的支持,这应该使您能够做您正在寻找的事情。

于 2013-10-16T22:21:08.690 回答