2012-05-10 48 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