Orbeon在radiobuttons的多语言奇怪的行为

时间:2015-10-15 10:06:19

标签: orbeon

我正在为我的orbeon表单添加一些多语言支持。对于此范围,我添加了几种具有不同语言<resource xml:lang="en">[...]</resource><resource xml:lang="it">[...]</resource>

的资源

我发现,如果我有两种语言,单选按钮选项会重复出现(我可以看到每个答案两次)。一个简单的例子是:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
     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: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:xi="http://www.w3.org/2001/XInclude"
     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:meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
            <xh:title>RadioButton</xh:title>
            <xf:model id="fr-form-model" xxf:expose-xpath-types="true">
                    <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
                            <metadata>
                                    <application-name>TestForm</application-name>
                                    <form-name>RadioButton_v1</form-name>
                                    <title xml:lang="en">RadioButton</title>
                                    <description xml:lang="en">Version: 1. Modification date: 2015-10-15 11:17:32. Publication date: 2015-10-15 11:17:32.</description>
                            <singleton>false</singleton>
            </metadata>
                    </xf:instance>
                    <xf:instance id="fr-form-instance">
                            <form>
                                    <Category>
                                            <Question>Answer</Question>
                                    </Category>
                            </form>
                    </xf:instance>
                    <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
                            <xf:bind id="Category-bind" name="Category" ref="/form/Category">
                                    <xf:bind id="Question-bind" name="Question" readonly="false()" ref="Question"
                         required="true()"/>
                            </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:exclude-result-prefixes="#all" xxf:readonly="false">
                            <resources>
                                    <resource xml:lang="en">
                                            <Category>
                                                    <label>Category</label>
                                                    <hint/>
                                                    <alert/>                                              
                                                    <Question>
                                                            <label>Question</label>
                                                            <hint/>
                                                            <alert/>
                                                            <item>
                                                                    <label>Answer</label>
                                                                    <hint/>
                                                                    <value>Answer</value>
                                                            </item>
                                                            <item>
                                                                    <label>Answer2</label>
                                                                    <hint/>
                                                                    <value>Answer2</value>
                                                            </item>
                                                            <item>
                                                                    <label>Answer3</label>
                                                                    <hint/>
                                                                    <value>Answer3</value>
                                                            </item>
                                                    </Question>
                                            </Category>
                                    </resource>       
                                    <resource xml:lang="nl">
                                            <Category>
                                                    <label>Category</label>
                                                    <hint/>
                                                    <alert/>
                                                    <Question>
                                                            <label>Question</label>
                                                            <hint/>
                                                            <alert/>
                                                            <item>
                                                                    <label>Answer</label>
                                                                    <hint/>
                                                                    <value>Answer</value>
                                                            </item>
                                                            <item>
                                                                    <label>Answer2</label>
                                                                    <hint/>
                                                                    <value>Answer2</value>
                                                            </item>
                                                            <item>
                                                                    <label>Answer3</label>
                                                                    <hint/>
                                                                    <value>Answer3</value>
                                                            </item>
                                                    </Question>
                                            </Category>
                                    </resource>
                            </resources>
                    </xf:instance>
                    <xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
                            <request/>
                    </xf:instance>
                    <xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
                            <response/>
                    </xf:instance>                       
            </xf:model>
    </xh:head>
    <xh:body>
            <fr:view>
                    <fr:body 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-bind" id="Category-control">
                                            <xf:label mediatype="text/html"
                          ref="instance('fr-form-resources')/resource/Category/label"/>
                                            <xf:hint ref="instance('fr-form-resources')/resource/Category/hint"/>
                                            <xf:alert ref="instance('fr-form-resources')/resource/Category/alert"/>
                                            <xh:tr>
                                                    <xh:td>
                                                            <xf:select1 appearance="full" bind="Question-bind" id="Question-control">
                                                                    <xf:label mediatype="text/html"
                                      ref="instance('fr-form-resources')/resource/Category/Question/label"/>
                                                                    <xf:hint ref="instance('fr-form-resources')/resource/Category/Question/hint"/>
                                                                    <xf:alert ref="instance('fr-form-resources')/resource/Category/Question/alert"/>
                                                                    <xf:itemset class="webforms-element webforms-answer"
                                        ref="instance('fr-form-resources')/resource/Category/Question/item">
                                                                            <xf:label ref="label"/>
                                                                            <xf:value ref="value"/>
                                                                            <xf:hint ref="hint"/>
                                                                    </xf:itemset>
                                                            </xf:select1>
                                                    </xh:td>
                                            </xh:tr>
                                    </fr:section>
                    </fr:body>
            </fr:view>
    </xh:body>
</xh:html>

结果如下:

Radio Button with repeated answers due to multilingual support

一项小型研究和测试,似乎该问题与部分定义中的“嵌套”问题有关。

<Category>
            <label>Category</label>
            <hint/>
            <alert/>
            <Question>
                    <label>Question</label>
                    <hint/>
                    <alert/>
            <item>
                    <label>Answer</label>
                    <hint/>
                    <value>Answer</value>
            </item>
            <item>
                    <label>Answer2</label>
                    <hint/>
                    <value>Answer2</value>
            </item>
            <item>
                     <label>Answer3</label>
                    <hint/>
                    <value>Answer3</value>
            </item>
     </Question>
</Category>

如果我将其更改为:

<Category>
            <label>Category</label>
            <hint/>
            <alert/>
</Category>
<Question>
            <label>Question</label>
            <hint/>
               <alert/>
            <item>
                    <label>Answer</label>
                    <hint/>
                    <value>Answer</value>
            </item>
            <item>
                    <label>Answer2</label>
                    <hint/>
                    <value>Answer2</value>
            </item>
            <item>
                     <label>Answer3</label>
                    <hint/>
                    <value>Answer3</value>
            </item>
</Question>

似乎工作正常。我知道Orbeon构建器不会在资源部分中执行嵌套元素,但总的来说我更喜欢这样做,我认为读取更清楚(或者使用元素的XPath)。

有什么方法可以使用嵌套元素来解决这种行为吗?

1 个答案:

答案 0 :(得分:0)

我认为你在最后一段回答了自己的问题:Form Runner并不希望资源以这种方式嵌套。

从本质上讲,Form Runner期望Form Builder生成的任何内容。如果您不使用表单生成器来编辑表单源,或者对表单生成器创建的源进行更改,则由您决定这些更改是否与表单生成器通常生成的内容一致,并且由Form Runner理解。