Possible to set two values for two different nodes from user input in XForms?
I would like to set two values for two different nodes from user input in XForms. I am curious about how this is done, if at all possible.
For example, if I have the following data model:
<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"/>
and my ui code looks like:
<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>
But I essentially want it to be like this (though this is invalid and does not produce any xml at all):
<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>
The XML output I want to achieve (if user checks "BBB"):
<criteria>
<set>
<root>/AAA</root>
<criterion>/@BBB</criterion>
</set>
</criteria>
How can I achieve setting these two nodes for the one checkbox seletion?
Hope that all made sense...
Thanks! :)
You should declare specific actions, such as "xf:setvalue", to be done on event "xforms-select".
-Alain
You could also use calculate:
<xf:bind nodeset="instance('criteria_data')/criteria/set/root" calculate="instance
('choices')/choice[. = instance('criteria_data')/criteria/set/criterion]/../root">
精彩评论