getodk / validate

ODK Validate is a Java application for confirming that a form is valid and compliant with the ODK XForms specification. Contribute and make the world a better place! ✨🔍✨
https://docs.getodk.org/validate/
Other
9 stars 26 forks source link

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

Closed joeflack4 closed 5 years ago

joeflack4 commented 5 years ago

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.

lognaturel commented 5 years ago

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 https://github.com/opendatakit/javarosa/issues/435.

lognaturel commented 5 years ago

I have opendatakit/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.

joeflack4 commented 5 years ago

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

lognaturel commented 5 years ago

I've confirmed that https://github.com/opendatakit/javarosa/pull/486 will fix this usage. It should be out in Collect v1.24 mid-October.