getodk/validate

Request: Add error for use of jr:choice-name() on question inside of repeat

joeflack4 opened this issue · 4 comments

Software versions

Validate v1.12.0 with JavaRosa v2.14.0
Java v1.8
JHU Collect v1.4.8e
OSX

Problem description

XLSForm code sample:

type name label calculate
begin repeat my_grp
select_one my_list my_list_q Select something.
my_choice calculate jr:choice-name(${my_list_q}, '${my_list_q}')
my_question text Was ${my_choice} your choice?

In this example, jr:choice-name() is being used on a question containing a list that is within a repeat group. Since, I believe, an instance of the repeat group is not being specified, the usage is invalid.

The result is that during runtime on the client, the expected text does not appear when interpolated (e.g. into a label/hint).

Steps to reproduce the problem

  1. Create an XLSForm that utilizes the above code example.
  2. Convert to XForm and run in ODK.
  3. Progress to the form until arriving at my_question.
  4. Observe issue as described above.

Expected behavior

ODK Validate should prevent erroneous usage of jr:choice-name() usage on a repeat group instance question/list without specifying an instance number.

My guess is that the problem here is that jr:choice-name does not support relative references but should. It's almost certainly a duplicate of getodk/javarosa#435.

I have getodk/javarosa#435 on my todo list for Collect v1.24 but if you want to look into it, @joeflack4, that would be wonderful.

To anyone looking at this, I think the first step should be to confirm/refute that it's a duplicate.

Yep, it does look redundant with that. I agree that the more ideal approach would be to resolve in JavaRosa, rather than Validate.

I've confirmed that getodk/javarosa#486 will fix this usage. It should be out in Collect v1.24 mid-October.