This is the revised proposal that includes translation support that @LN and I have come up with and want to present for further discussion. It includes additional label parameters with a language code (e.g.
label_fr) as shown in this example:
||value=id label_en=species label_fr=espèces
It works the same with XML external data files. It also works with choice_filters (so unchanged).
Compared to Enketo's rogue feature mentioned above this proposal does not require a specific CSV data structure, except that column headings should (ideally) be valid XML node names (we could work around that limitation though). So it provides the ultimate CSV flexibility. A small disadvantage is that it wouldn't work with XML files that use e.g
lang attributes to provide translations. However, since we require a specific XML structure (
root > item) for
select_from_file anyway, that does not seem a big deal.
The earlier example without translations remains unchanged.
Pyxform would produce the following output (ignore this if you're not an XForm enthusiast or developer):
<translation default="true()" lang="English (en)">
<translation lang="French (fr)">
<instance id="my_data" src="jr://file-csv/mydata.csv" />
<label ref="./*[local-name() = jr:itext('external_instance-my_data-0')]"/>
The reason for introducing
local-name() instead of
name() is to provide better support for external XML data which will likely be name-spaced.
local-name() will ignore the namespace prefix.
(Not 100% sure if this ref value is XForms-compliant. Tbc.)
Any feedback would be very welcome!
P.S. Thanks @LN! Note, that I made a few tweaks to change parameter
name back to
value in XLSForm, use
* instead of
node() and changed the example to not use