Orbeon如何在下拉列表中进行选择验证

时间:2018-08-14 07:29:46

标签: validation drop-down-menu orbeon

  • 我有一个下拉列表(动物),里面有猪,牛,马。
  • 我有一个(动物数量)字段。
  • 我有一个“总重量”字段。

我在下拉列表中选择一种动物,输入动物数并输入总重量。动物的体重不同,如果总重量超出特定动物的限制,我必须提出警告。

我尝试使用以下公式进行验证:if ($Animal='Pigs') then ($Weight > $Number*200) else ($Weight < $Number*700)

我想下拉列表中的每个选择都必须有一个公式。 它无法正常工作,我无法找到解决方案。 请帮助,我也想知道-如果无法完成。:)

嗨,Avernet-谢谢。我希望我在下面添加了足够的信息:

Control

来源:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
         xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
         xmlns:exf="http://www.exforms.org/exf/1-0"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:saxon="http://saxon.sf.net/"
         xmlns:sql="http://orbeon.org/oxf/xml/sql"
         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
         xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
         fr:data-format-version="4.0.0">
    <xh:head>
        <xh:title>Slagtetal test</xh:title>
        <xf:model id="fr-form-model" xxf:expose-xpath-types="true">
            <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
                <form>



                    <section-16>
                        <grid-17>
                            <grid-17-iteration>
                                <Species/>
                                <Number/>
                                <Weight/>
                            </grid-17-iteration>
                        </grid-17>
                    </section-16>


                </form>
            </xf:instance>
            <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">



                <xf:bind id="section-16-bind" ref="section-16" name="section-16">
                    <xf:bind id="grid-17-bind" ref="grid-17" name="grid-17">
                        <xf:bind id="grid-17-iteration-bind" ref="grid-17-iteration" name="grid-17-iteration">
                            <xf:bind id="Species-bind" ref="Species" name="Species" required="true()"/>
                            <xf:bind id="Number-bind" ref="Number" name="Number" required="true()" type="xs:integer"/>
                            <xf:bind id="Weight-bind" ref="Weight" name="Weight" type="xf:decimal">
                                <xf:constraint id="validation-34-validation"
                                               value="if ($Species='Heste') then ($Weight &gt; $Number*200) else ($Weight &lt; $Number*700)"/>

                            </xf:bind>
                        </xf:bind>
                    </xf:bind>
                </xf:bind>


            </xf:bind>
            <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
                <metadata>
                    <application-name>24</application-name>
                    <form-name>Slagtetal-test</form-name>
                    <title xml:lang="da">Slagtetal test</title>
                    <description xml:lang="da">Test af funktioner i blanketten</description>
                    <singleton>false</singleton>
                    <permissions>
                        <permission operations="update delete">
                            <owner/>
                        </permission>
                        <permission operations="create read"/>
                    </permissions>
                </metadata>
            </xf:instance>
            <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
                <attachments>
                    <css mediatype="text/css" filename="" size=""/>
                    <pdf mediatype="application/pdf" filename="" size=""/>
                </attachments>
            </xf:instance>
            <xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
                <resources>
                    <resource xml:lang="da">




                        <Species>
                            <label>Animal species</label>
                            <hint/>
                            <item>
                                <label>Kvæg over 150kg over 2år</label>
                                <value>kvæg-over-150kg-over-2år</value>
                            </item>
                            <item>
                                <label>Kvæg over 150kg under 2år</label>
                                <value>kvæg-over-150kg-under-2år</value>
                            </item>
                            <item>
                                <label>Kvæg under 150kg</label>
                                <value>kvæg-under-150kg</value>
                            </item>
                            <item>
                                <label>Svin over 27kg</label>
                                <value>svin-over-27kg</value>
                            </item>
                            <item>
                                <label>Svin under 27kg</label>
                                <value>svin-under-27kg</value>
                            </item>
                            <item>
                                <label>Søer og orner</label>
                                <value>søer-og-orner</value>
                            </item>
                            <item>
                                <label>Vildsvin nedlagt</label>
                                <value>vildsvin-nedlagt</value>
                            </item>
                            <item>
                                <label>Vildsvin opdrættet</label>
                                <value>vildsvin-opdrættet</value>
                            </item>
                            <item>
                                <label>Får og geder 12-18kg over 18mdr</label>
                                <value>får-og-geder-12-18kg-over-18mdr</value>
                            </item>
                            <item>
                                <label>Får og geder 12-18kg under 18mdr</label>
                                <value>får-og-geder-12-18kg-under-18mdr</value>
                            </item>
                            <item>
                                <label>Får og geder over 18kg under 18mdr</label>
                                <value>får-og-geder-over-18kg-under-18mdr</value>
                            </item>
                            <item>
                                <label>Får og geder over 18kg over 18mdr</label>
                                <value>får-og-geder-over-18kg-over-18mdr</value>
                            </item>
                            <item>
                                <label>Får og geder under 12kg</label>
                                <value>får-og-geder-under-12kg</value>
                            </item>
                            <item>
                                <label>Hjorte og andre drøvtyggere 12-18kg nedlagt</label>
                                <value>hjorte-og-andre-drøvtyggere-12-18kg-nedlagt</value>
                            </item>
                            <item>
                                <label>Hjorte og andre drøvtyggere 12-18kg opdrættet</label>
                                <value>hjorte-og-andre-drøvtyggere-12-18kg-opdrættet</value>
                            </item>
                            <item>
                                <label>Hjorte og andre drøvtyggere over 18kg nedlagt</label>
                                <value>hjorte-og-andre-drøvtyggere-over-18kg-nedlagt</value>
                            </item>
                            <item>
                                <label>Hjorte og andre drøvtyggere over 18kg opdrættet</label>
                                <value>hjorte-og-andre-drøvtyggere-over-18kg-opdrættet</value>
                            </item>
                            <item>
                                <label>Hjorte og andre drøvtyggere under 12kg nedlagt</label>
                                <value>hjorte-og-andre-drøvtyggere-under-12kg-nedlagt</value>
                            </item>
                            <item>
                                <label>Hjorte og andre drøvtyggere under 12kg opdrættet</label>
                                <value>hjorte-og-andre-drøvtyggere-under-12kg-opdrættet</value>
                            </item>
                            <item>
                                <label>Gæs 2-5kg</label>
                                <value>gæs-2-5kg</value>
                            </item>
                            <item>
                                <label>Gæs over 5kg</label>
                                <value>gæs-over-5kg</value>
                            </item>
                            <item>
                                <label>Gæs under 2kg</label>
                                <value>gæs-under-2kg</value>
                            </item>
                            <item>
                                <label>Høns</label>
                                <value>høns</value>
                            </item>
                            <item>
                                <label>Kyllinger</label>
                                <value>kyllinger</value>
                            </item>
                            <item>
                                <label>Duer</label>
                                <value>duer</value>
                            </item>
                            <item>
                                <label>Ænder</label>
                                <value>ænder</value>
                            </item>
                            <item>
                                <label>Kalkuner over 5kg</label>
                                <value>kalkuner-over-5kg</value>
                            </item>
                            <item>
                                <label>Kaniner og småhårvildt under 2kg</label>
                                <value>kaniner-og-småhårvildt-under-2kg</value>
                            </item>
                            <item>
                                <label>Kaniner og småhårvildt over 2kg</label>
                                <value>kaniner-og-småhårvildt-over-2kg</value>
                            </item>
                            <item>
                                <label>Kaniner og småhårvildt</label>
                                <value>kaniner-og-småhårvildt</value>
                            </item>
                            <item>
                                <label>Heste</label>
                                <value>heste</value>
                            </item>
                            <item>
                                <label>Opskåret kød (egne slagtninger)</label>
                                <value>opskåret-kød-(egne-slagtninger)</value>
                            </item>
                            <item>
                                <label>Opskåret kød ialt</label>
                                <value>opskåret-kød-ialt</value>
                            </item>
                            <item>
                                <label>Andre K &amp; V nedlagt</label>
                                <value>andre-k-&amp;-v-nedlagt</value>
                            </item>
                            <item>
                                <label>Andre K &amp; V opdrættet</label>
                                <value>andre-k-&amp;-v-opdrættet</value>
                            </item>
                        </Species>
                        <Number>
                            <label>Number of slaughtered animals</label>
                            <hint/>
                        </Number>
                        <Weight>
                            <label>Slaughtered weight</label>
                            <hint/>
                            <alert>Wrong slaughtered weight</alert>

                        </Weight>







                        <section-16>
                            <label>3. Dyreart</label>
                            <help/>
                        </section-16>


                    </resource>
                </resources>
            </xf:instance>
            <xf:instance xxf:readonly="true" xxf:exclude-result-prefixes="#all" id="grid-17-template">
                <grid-17-iteration>
                    <Species/>
                    <Number/>
                    <Weight/>
                </grid-17-iteration>
            </xf:instance>
        </xf:model>
    </xh:head>
    <xh:body>
        <fr:view>
            <fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline"
                     xmlns:oxf="http://www.orbeon.com/oxf/processors">



                <fr:section id="section-16-control" bind="section-16-bind">
                    <xf:label ref="$form-resources/section-16/label"/>
                    <fr:grid id="grid-17-grid" bind="grid-17-bind" repeat="content" min="1"
                             template="instance('grid-17-template')">
                        <fr:c y="1" x="1" w="4">
                            <xf:select1 id="Species-control" bind="Species-bind" appearance="dropdown">
                                <xf:label ref="$form-resources/Species/label"/>
                                <xf:hint ref="$form-resources/Species/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>

                                <xf:itemset ref="$form-resources/Species/item">
                                    <xf:label ref="label"/>
                                    <xf:value ref="value"/>
                                </xf:itemset>
                            </xf:select1>
                        </fr:c>
                        <fr:c y="1" x="5" w="4">
                            <fr:number id="Number-control" bind="Number-bind">
                                <xf:label ref="$form-resources/Number/label"/>
                                <xf:hint ref="$form-resources/Number/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>

                            </fr:number>
                        </fr:c>
                        <fr:c y="1" x="9" w="4">
                            <fr:number id="Weight-control" bind="Weight-bind">
                                <xf:label ref="$form-resources/Weight/label"/>
                                <xf:hint ref="$form-resources/Weight/hint"/>
                                <xf:alert ref="$form-resources/Weight/alert" validation="validation-34-validation"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>


                            </fr:number>
                        </fr:c>
                    </fr:grid>
                </fr:section>


            </fr:body>
        </fr:view>
    </xh:body>
</xh:html>

0 个答案:

没有答案