2
votes

(I'm just starting out with xforms)

I have a form with 10 integer entry fields and 1 text field I'm trying to set a relevant criteria on a text field. What I want to do is display the text field if and only if the value of one or more of the fields is higher than 18.

I believe I need an or condition in the relevant field, something like: relevant="(/data/weight_group/weight1 > 18 || /data/weight_group/weight2 > 18)"

Obviously that's not exactly right, but I can't find anything even close on Google/Stack/etc., leading me to believe that I'm barking up the wrong tree.

Any suggestions? Thanks

2

2 Answers

1
votes

It should be something like this:

relevant="/data/weight_group/weight1 < 18 or /data/weight_group/weight2 > 18"

Some explanations:

  • The value of relevant property is XPath expression. So you need to consult XPath documentation when something doesn't work.
  • Logical operators in XPath are "and" and "or", not "&&" and "||".
  • You need to escape < and > in XPath expressions as &lt; and &gt;, so that they don't mess up the XML structure. (Can someone confirm this?)
0
votes

Firstly the relevant property is a model property, that means it does not work on the controls. Secondly it is updated via a bind element.

<model  xmlns="http://www.w3.org/2002/xforms">
  <instance>
     <data xmlns="">
        <weight_group>
           <weight1/><weight2/>
        </weight_group>
        <valid_weight>
     </data>
  </instance>
  <bind nodeset="/data/valid_weight" relevant="../weight_group/weight1 &lt; 18 or ../weight_group/weight2 &gt; 18">
</model>

To the property valid_weight is controlled by this condition, and any control bound to valid weight will disappear when not relevant.