Referencing values in internal datasets

1. What is the problem? Be very detailed.
I am simply trying to reference a value from the internal dataset (from choices) as described in the documentation. However, my form fails to even load due to the error:

Error: ODK Validate Errors:
>> Something broke the parser. See above for a hint.
Error evaluating field 'pop_calc' (${pop_calc}[1]): The problem was located in Calculate expression for ${pop_calc}
XPath evaluation: Instance referenced by instance(states)/root/item/population does not exist
Caused by: org.javarosa.xpath.XPathMissingInstanceException: The problem was located in Calculate expression for ${pop_calc}
XPath evaluation: Instance referenced by instance(states)/root/item/population does not exist
	... 10 more

The following files failed validation:
${enketo_widgets}.xml

Result: Invalid

Clearly something is messed up with my form config, but I cannot figure out what it is since I basically just copied the example from the documentation.

enketo_widgets.xlsx (12.5 KB)

2. What app or server are you using and on what device and operating system? Include version numbers.

I am just testing the form out on https://getodk.org/xlsform/

3. What you have you tried to fix the problem?

I have tried various tweaks to the configuration (e.g. wrapping the whole calculation in string), but nothing has helped.

4. What steps can we take to reproduce the problem?

Use https://getodk.org/xlsform/ to convert a form that contains the configuration example from the internal dataset documentation.

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Thanks!

survey:

type name label calculation
select_one states state State
calculate pop_calc Population for selected state instance("states")/root/item[name = ${state}]/population
note pop_note Population: ${pop_calc}

choices:

list_name name label population
states abia Abia 4112230
states ebonyi Ebonyi 2176947

Okay, I guess I answered my own question. What my config was missing was true() (or any other value?) in the choice_filter column for my select. For some reason this is required to cause the instance data from choices to be included.

There is a note about this buried in the documentation that indicates it is a "bug" in pyxform. There is more discussion on this pyxform issue.

1 Like