次のようなxmlがあります。
<table1>
<row>
<person>person1</person>
<value>10</value>
</row>
<row>
<person>person2</person>
<value>20</value>
</row>
<row>
<person>person1</person>
<value>5</value>
</row>
</table1>
<summaryTable>
<row>
<person>person1</person>
<value_total/>
</row>
<row>
<person>person2</person>
<value_total/>
</row>
</summaryTable>
XForms 1 (XForms 2 に切り替えるオプションはありません) では、フレームワークの betterform を使用して、同じ人の名前を持つ「table1」の行の合計を実行して、集計テーブルの値を計算したいと考えています。そのために、次のバインドがあります。
<xf:bind id="bind_table1"
nodeset="table1" repeatableElement="row">
<xf:bind id="bind_head_table1" nodeset="head" />
<xf:bind id="bind_row_table1" nodeset="row">
<xf:bind id="bind_person" nodeset="person" type="xf:string" />
<xf:bind id="bind_value" nodeset="value" type="xf:integer" />
</xf:bind>
</xf:bind>
<xf:bind id="bind_summaryTable"
nodeset="summaryTable"
repeatableElement="row">
<xf:bind id="bind_head_summaryTable" nodeset="head" />
<xf:bind id="bind_row_summaryTable" nodeset="row">
<xf:bind id="bind_person_name" nodeset="person_name" type="xf:string" readonly="true"/>
<xf:bind id="bind_value_total" nodeset="value_total" type="xf:integer" readonly="true" calculate="SUM(//table1/row[person/text() = ../person_name/text()]/value)"/>
</xf:bind>
</xf:bind>
最後に必要なのは、person1 の value_total = 15 と person2 の value_total = 20 ですが、この「計算」式を使用すると、「NaN」が得られます。計算式を置き換えて、次のような文字列リテラルと比較すると:
<xf:bind id="bind_value_total" nodeset="value_total" type="xf:integer" readonly="true" calculate="SUM(//table1/row[person/text() = 'person1']/value)"/>
次に、value_total 15 を取得します (合計は正しく行われます)。したがって、エラーは比較式 person/text() = ../person_name/text() にあるようです。誰かがどのように正しい表現であるべきかについて考えを持っていますか?
ありがとう