In one form I need to use
(1) cascading select for one question, then
(2) a dynamic select from a csv file (search()
) and
(3) select data from that file using pull_data
.
I can make each two of them working together but never three. When I have pull_data
and cascades working, simply adding definition of cd.csv for search()
function
list name, name, label
cd, cd_key, cd_text
into choices sheet causes an error while converting with xls2xform
Traceback (most recent call last):
File "/Users/mix/anaconda3/bin/xls2xform", line 10, in <module>
sys.exit(main_cli())
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/xls2xform.py", line 177, in main_cli
enketo=args.enketo_validate,
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/xls2xform.py", line 49, in xls2xform_convert
enketo=enketo,
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/survey.py", line 915, in print_xform_to_file
raise error
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/survey.py", line 911, in print_xform_to_file
file_obj.write(self._to_ugly_xml())
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/survey.py", line 771, in _to_ugly_xml
return '<?xml version="1.0"?>' + self.xml().toxml()
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/survey.py", line 198, in xml
node("h:head", node("h:title", self.title), self.xml_model()),
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/survey.py", line 496, in xml_model
model_children += list(self._generate_instances())
File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/survey.py", line 472, in _generate_instances
raise PyXFormError(msg)
pyxform.errors.PyXFormError: The same instance id will be generated for different external instance source URIs. Please check the form. Instance name: 'cd', Existing type: 'pulldata', Existing URI: 'jr://file-csv/cd.csv', Duplicate type: 'choice', Duplicate URI: 'None', Duplicate context: 'survey'.
My cd.csv:
cd_key cd_text
A16.9 Tuberculosis
T14.1 Animal bite
and simple form:
that contains
pulldata('cd', 'cd_text', 'cd_key', ${disease_selection})
and unrelated cascading select using choice_filter
.
Removing choice_filter
also allows form to compile.
What am I doing wrong? I realise that I can use a search()
for cascading select with external data, which I'll do for now, but would like to understand why it doesn't work: is it by design, or a bug?
Thanks,
M