How can I use relevance to only show an image field if the prior image field has a value

I believe Enketo might be correct here... :slight_smile: If the question (XML node) exists, it is true (in XPath), regardless of its value. And in this case the XPath expression is a node-set which is converted to a boolean.

Many times, I have been confused about his part of the XPath spec too (here "non-empty" does not refer to the node values but to whether there are any nodes in the node-set).

You could also double-check with the native XPath evaluator with something like this (which I think is what Enketo uses in this case):

const xmlDoc = new DOMParser().parseFromString('<data><a></a></data>', 'text/xml'); 
xmlDoc.evaluate('/data/a', xmlDoc.documentElement, null, XPathResult.BOOLEAN_TYPE).booleanValue

1 Like