0

我有以下实例:

<xforms:instance id="fr-form-instance">
    <form>
        <section-1>
            <control-1>
                <en>Nothing special.</en>
                <ro>Nimic special.</ro>
            </control-1>
        </section-1>
    </form>
</xforms:instance>

我想添加一个输入以读取和编辑所选语言的值,如下所示:

...
<xhtml:td>
    <xforms:output value="instance('fr-form-instance')/section-1/control-1/*[name()=xxforms:lang()]"/>
    <xforms:input id="control-1-control" ref="instance('fr-form-instance')/section-1/control-1/*[name()=xxforms:lang()]"/>
</xhtml:td>
...

问题是输出文本正确显示,如果我更改语言,文本也会更改,但输入字段不会出现。如果我将 xpath 更改为使用[name()='ro']而不是[name()=xxforms:lang],它可以工作。我怎样才能让它动态工作?

4

1 回答 1

0

这似乎对我有用。我得到:

在此处输入图像描述

从语言选择器中选择“română”时:

在此处输入图像描述

我已经粘贴在表格的完整来源下面,以防您想复制它。我用 Orbeon Forms 4.0 对此进行了测试。

<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">
    <xh:head>
        <xh:title/>
        <xf:model id="fr-form-model" xxf:expose-xpath-types="true">

            <!-- Main instance -->
            <xf:instance id="fr-form-instance">
                <form>
                    <section-1>
                        <control-1>
                            <en>Nothing special.</en>
                            <ro>Nimic special.</ro>
                        </control-1>
                    </section-1>
                </form>
            </xf:instance>

            <!-- Bindings -->
            <xf:bind xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" id="fr-form-binds"
                     ref="instance('fr-form-instance')">
                <xf:bind id="section-1-bind" name="section-1" ref="section-1">

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

            <!-- Metadata -->
            <xf:instance xxf:readonly="true" id="fr-form-metadata">
                <metadata>
                    <application-name>a</application-name>
                    <form-name>a</form-name>
                    <title xml:lang="en"/>
                    <description xml:lang="en"/>
                    <title xml:lang="ro"/>
                    <description xml:lang="ro"/>


                </metadata>
            </xf:instance>

            <!-- Attachments -->
            <xf:instance id="fr-form-attachments">
                <attachments>
                    <css mediatype="text/css" filename="" size=""/>
                    <pdf mediatype="application/pdf" filename="" size=""/>
                </attachments>
            </xf:instance>

            <!-- All form resources -->
            <!-- Don't make readonly by default in case a service modifies the resources -->
            <xf:instance id="fr-form-resources" xxf:readonly="false">
                <resources>
                    <resource xml:lang="en">
                        <section-1>
                            <label/>
                            <help/>
                        </section-1>

                    </resource>
                    <resource xml:lang="ro">
                        <section-1>
                            <label/>
                            <help/>
                        </section-1>

                    </resource>

                </resources>
            </xf:instance>

            <!-- Utility instances for services -->
            <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:xbl="http://www.w3.org/ns/xbl"
                     xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel"
                     xmlns:oxf="http://www.orbeon.com/oxf/processors"
                     xmlns:p="http://www.orbeon.com/oxf/pipeline">
                <fr:section id="section-1-control" bind="section-1-bind">
                    <xf:label ref="$form-resources/section-1/label"/>
                    <xf:help ref="$form-resources/section-1/help"/>
                    <fr:grid>
                        <xh:tr>
                            <xh:td>
                                <xf:output value="instance('fr-form-instance')/section-1/control-1/*[name()=xxforms:lang()]"/>
                                <xf:input id="control-1-control"
                                          ref="instance('fr-form-instance')/section-1/control-1/*[name()=xxforms:lang()]"/>
                            </xh:td>
                            <xh:td/>
                        </xh:tr>
                    </fr:grid>
                </fr:section>
            </fr:body>
        </fr:view>
    </xh:body>
</xh:html>
于 2013-02-27T01:14:45.470 回答