我想从XForms中的用户输入为两个不同的节点设置两个值。如果可能的话,我很好奇这是怎么做到的。
例如,如果我有以下数据模型:
<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"/>
我的用户界面代码如下:
<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>
如何为一个复选框选择设置这两个节点?
希望一切都有意义…
谢谢!:)