Closed MartijnR closed 3 years ago
ping @pbowen-oc
Thanks for logging this, @MartijnR
@gushil - Can you please work on this?
@pbowen-oc Working on it.
Hi @MartijnR, I've created PR #485 to fix this issue. Waiting for review. Thanks
Looks like the form posted here slips through the cracks: https://github.com/OpenClinica/enketo-express-oc/issues/398#issuecomment-745082006 . See both (similar) indexed-repeat() calls.
One of them is:
if(position(..) = 1, '', indexed-repeat(${bp_sys}, ${bp_rg}, position(..) - 1))
@gushil - Can you take a look at this?
@pbowen-oc working on it
@MartijnR I've created a new PR (#499) to solve the issue @pbowen-oc mentioned.
Thanks.
Software and hardware versions
2.2.1
Problem description
The first argument of indexed-repeat() calls is relative when called from inside a repeat and referring to a question in that repeat. It should be absolute.
A
../relative/path/to/question
always returns a single node (in ODK XForms) and according to the spec it should refer to all nodes with that question name, i.e. the nodeset returned by/absolute/path/to/question
.Steps to reproduce the problem
A. using regular calculation with relative index:
outputs:
B. using dynamic default:
outputs:
C. using dreaded nested repeats:
outputs:
Expected behavior
A:
B:
C:
So the first argument of indexed-repeat() is an exception to the relative-path rule used to transform ${node} syntax (and the second argument too but that seems to already be the case).
Or actually since indexed-repeat() has either 3, 5, or 7 arguments, this exception applies to the 1st, 2nd, 4th, and 6th arguments.
Other information
Previously using indexed-repeat() inside a repeat was a bit of an edge case. Since the introduction of dynamic defaults it is becoming more common, as you could use the answer of a previous repeat question as the dynamic default of that same question in a new repeat instance (example B).
I'm guessing this issue was introduced in 0.12.0 when we changed to relative node references inside repeats.