XForms のユーザー入力から 2 つの異なるノードに 2 つの値を設定したいと考えています。可能であれば、これがどのように行われるのか興味があります。
たとえば、次のデータ モデルがあるとします。
<xf:instance id="criteria_data" xmlns="">
<criteria>
<set>
<root></root>
<criterion></criterion>
</set>
</criteria>
</xf:instance>
<xf:instance id="choices" xmlns="">
<choices>
<root label="The Choices">/AAA</root>
<choice label="BBB">/@BBB</choice>
</choices>
</xf:instance>
<xf:instance id="choices" xmlns="">
<choices>
<root>/AAA</root>
<choice label="BBB">/@BBB</choice>
<choice label="CCC">/@CCC</choice>
<choices>
</xf:instance>
<xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/set/criterion"/>
<xf:bind id="data_root" nodeset="instance('criteria_data')/criteria/set/root"/>
<xf:bind id="choices_root" nodeset="instance('choices')/root"/>
<xf:bind id="choices" nodeset="instance('choices')/choice"/>
そして私のUIコードは次のようになります:
<xf:select bind="data_criterion" appearance="full">
<xf:label>Your choices:</xf:label>
<xf:itemset bind="choices">
<xf:label ref="@label"></xf:label>
<xf:value ref="."></xf:value>
</xf:itemset>
</xf:select>
しかし、私は基本的に次のようにしたいと考えています (ただし、これは無効であり、xml はまったく生成されません)。
<xf:select appearance="full">
<xf:label>Your choices:</xf:label>
<xf:itemset bind="choices">
<xf:label ref="@label"></xf:label>
<xf:value bind="data_criterion" ref="."></xf:value>
<xf:value bind="data_root" ref="instance('choices')/root"></xf:value>
</xf:itemset>
</xf:select>
達成したいXML出力(ユーザーが「BBB」をチェックした場合):
<criteria>
<set>
<root>/AAA</root>
<criterion>/@BBB</criterion>
</set>
</criteria>
1 つのチェックボックスの選択に対してこれら 2 つのノードを設定するにはどうすればよいですか?
すべてが理にかなっていることを願っています...
ありがとう!:)