Search code examples
xforms

xforms - relevant with OR condition


(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


Solution

  • 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?)