XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
77 stars 134 forks source link

Trigger referring to repeat question has relative ref attribute #477

Closed MartijnR closed 3 years ago

MartijnR commented 3 years ago

Software and hardware versions

Last commit in master of Oct 29th, 2020

Problem description

If a trigger refers to a question inside a repeat, the ref attribute value is relative. Though this is strictly speaking correct in XForms, in pyxform we've so far always used absolute references and could do so in this case too. This would be more consistent. The real problem is that a relative reference doesn't work in Enketo is not so easy to add support for.

Steps to reproduce the problem

type name label trigger calculation
begin repeat rep      
text one Enter text    
text three Enter text (triggered) ${one} concat('d', 'e')
end repeat        

This form doesn't pass ODK Validate (different issue) so run with --skip_validate.

The output contains <setvalue event="xforms-value-changed" ref=" ../three " value="concat('d', 'e')" />

Note the inconsistency with the other ref attributes in the same body that are all absolute including the three question itself.

Desired behavior

The desired output would contain <setvalue event="xforms-value-changed" ref=" /data/rep/three " value="concat('d', 'e')" /> instead.

Additional information

Both ref="/data/rep/three" attributes in the (desired) output refer to the same node (in the current repeat instance). They are binding expressions. As far as I can tell they have the exact same meaning in XForms.

lognaturel commented 3 years ago

Thanks, @MartijnR, this makes sense. I think the Validate issue is actually the same one -- currently the ref is being contextualized against the root so ../three parents beyond what makes sense.

MartijnR commented 3 years ago

Thank you. That's very good, as we don't have to feel so bad about not supporting that in Enketo then! 👍 😆

pbowen-oc commented 3 years ago

One of our developers at OpenClinica can work on this.

@gushil - Please take a look.

gushil commented 3 years ago

Hi, @MartijnR I've created PR #478 to fix this issue.

Thanks.