Orbeon Xforms nested repeats

泄露秘密 提交于 2019-12-11 08:28:39

问题


I am trying to create a form with nested repeats that runs in Orbeon server. The idea is to have some elements that can be repeated and other elements inside the first one, that also can be repeated. i.e a block for inserting personal information (for several persons in a repeat) and for each person, we can add several phone numbers (also a repeat).

I have not found so much information about how to do it, and I suppose that I can create this: Other StackOverflow question (but this example also does not work for me, even with the corrections exposed in the comments).

For testing I have created the next form:

<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>

But only the "nested repeat" is shown and not the "external" one.

The question is: Is it not implemented in Orbeon? Do It needs an specific syntax? Or is there any error that I cannot see?

I am using Orbeon 4.3.0.1.201308150213-CE.

EDITED: I have changed the loops' "template" section with some corrections.


回答1:


Nesting <fr:grid> isn't supported at this point. But we're planning to soon implement support for nested sections, which should enable you to do what you're looking for.



来源:https://stackoverflow.com/questions/19321370/orbeon-xforms-nested-repeats

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!