我想創建一個窗體,在Orbeon服務器中運行嵌套重複。這個想法是有一些可以重複的元素和第一個元素中的其他元素,也可以重複。即用於插入個人信息的塊(對於多人重複)並且對於每個人,我們可以添加多個電話號碼(也是重複的)。Orbeon Xforms嵌套重複
我還沒有發現如何做到這麼多的信息,我想我可以創建這個:Other StackOverflow question(但這個例子也不適用於我,即使在評論中公開了更正)。
爲了測試我創建了一個表格:
<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。
編輯: 我已更改循環的「模板」部分與一些更正。
該應用程序的範圍是在Orbeon中部署一個可用於填充信息的表單,不僅用於表示存儲的數據。 – JorgeHortelano
這是你在Form Builder中創建的表單嗎?此時,Form Builder不支持嵌套重複,因此如果您確實需要嵌套重複,則需要手動編寫表單。請注意,我們正在考慮在不久的將來支持重複部分,這些部分應該處理像這樣的用例。 – avernet
表單的基礎由表單生成器創建,但嵌套循環是由手工創建的。我不確定這是否是執行嵌套循環的正確方法。 – JorgeHortelano