2012-05-10 47 views
0

情況如下:插入例如在重複

  1. 我有一個節點集,通過它我迭代,並填充表的一些數據
  2. 一個字段的,我確實要總結

問題: 不幸的是我不能用總和法計算的節點集是來自OT訪問數據的自定義功能她的形式。這似乎弄亂了事情。

我對解決方案的想法: 我想,我可以創建一個實例,並在每次迭代中爲其添加值。然後,我可以訪問這些數據並進行所需的任何計算。但我無法使xforms:insert工作。

的簡化版本是這樣的:

  <xforms:repeat nodeset="(xxforms:si-source-forms('other_form'))"> 
       <!-- table here --> 
       <xforms:insert 
       nodeset="instance('fr-form-instance')//positionen/position" 
       origin="instance('neue-position')"/> 
      </xforms:repeat> 

的「抵達Neue位置」實例包含綁定的源代碼形式的值:

<xforms:bind id="neue-position-binds" nodeset="instance('neue-position')"> 
    <xforms:bind id="neue-position-bind" nodeset="position"> 
     <xforms:bind id="neue-position-summe-bind" nodeset="summe" name="summe" type="xforms:string" required="true" xxforms:default="xxforms:si-source-forms('other_form')//gesamtbetrag_ausgabe" /> 
    </xforms:bind> 
    </xforms:bind> 

如同預期它不工作,所以顯然有一些錯誤。我會很感激任何提示。

回答

1

關於您的第一個代碼段:

<xforms:insert>不會有任何effet。您處於視圖中,並且僅當它附加到事件偵聽器時纔會運行一個操作。沒有 <xforms:insert>(或圍繞該插入操作),它不會運行。

關於不在一個實例做了節點和:

假設只有一個「和」在你的自定義函數返回的數據,你可以沿着這些線路寫代碼:

  1. 存儲由函數的變量<xf:var name="others" ref="xxforms:si-source-forms('other_form')"/>
  2. 返回使用該變量在重複節點的順序:<xf:repeat ref="$others">(順便說一句,現在XForms的規範使用ref無處不在,代替nodeset)。
  3. 做你的計算:<xf:var name="my-sum" ref="sum($others/path/to/values)"/>
  4. 最後,我想你想用$my-sum做些什麼,也許用<xf:output>來表明它。
+0

感謝您的支持,它讓我走向正確的方向。 – dhenze