getodk/javarosa

indexed-repeat does not work when the first parameter is a relative reference

Closed this issue · 1 comments

Software versions

JavaRosa v2.16

Problem description

indexed-repeat does not work when the first parameter is a relative reference. This is problematic because pyxform now outputs relative references within repeats.

Possibly encountered by user at https://forum.opendatakit.org/t/indexed-repeat-used-in-a-repeat-nested-in-a-repeat-returns-wrong-value/17748/37.

Steps to reproduce the problem

  1. Convert an XLSForm form such as this one which has an indexed-repeat call in a nested repeat that attempts to refer to a value in the parent repeat. Note that the result of the indexed-repeat call should be identical to ../../uuid.
  2. Try it in JavaRosa and see that the function call crashes with parameter 2 must be a parent of the field in parameter 1.

Expected behavior

It should be possible to use indexed-repeat with a relative reference for the first parameter. The node that the indexed-repeat call happens on should be used as the context node.

Other information

Related to #435

I have a failing test at 423b1ff with the sample form linked to above.

I briefly looked at the indexed-repeat implementation but it doesn't look like what I expected so it's going to take some digging.

For QA: the XLSForm I linked to above used to have the working ../../uuid expression instead of the indexed-repeat one. I've modified it. Form conversion doesn't work with the online conversion tool because of Validate so the XML is indexed-repeat-nested.xml.zip.