2013-02-19 50 views
0

我有以下實例:Orbeon在ref屬性動態的XPath

<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],則它可以正常工作。 我該如何使其動態工作?

+0

你使用Form Runner嗎?你如何改變語言? – ebruchez 2013-02-22 06:55:39

+0

是的,我正在使用Form Runner。通過點擊右上角的可用語言來更改語言。 – 2013-02-22 10:17:35

回答

0

這似乎是爲我工作。我得到:

enter image description here

而且從語言選擇器中選擇時,「羅馬」:

enter image description here

我粘貼形式的完整源代碼如下,如果你想重現這個。我用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> 
+0

謝謝你的迴應。我使用orbeon 3.9。 – 2013-02-27 14:23:25

+0

我不知道爲什麼這不是3.9的工作;它看起來像一個bug。無論如何,如果可以的話,我會建議你升級到4.0,這固定了很多問題,並且有許多新功能。 – avernet 2013-02-28 03:37:56