XForms

Enketo supports the ODK/OpenRosa XForms format.

See the Form Building section for guidance on creating compatible survey forms.

External CSV Data

Enketo supports the XForms specification for adding external XML data using the jr://file connector.

In addition, Enketo has support for external CSV files using the jr://file-csv connector. We are hopeful this method will become part of the common ODK/OpenRosa specification eventually.

<instance id="households" src="jr://file-csv/households.csv"/>

If an external CSV file is added as an external instance, Enketo will use a fixed CSV-to-XML transformation to facilitate querying this data in any XPath expression. This transformation is identical to the transformation performed by pyxform, as illustrated below.

name label rooms
0001 Johnson 2
0034 Doe 5
0021 Rijdt 1

The above table is transformed into the following XML (children of <instance id="households"/>):

<root>
  <item>
    <name>0001</name>
    <label>Johnson</label>
    <rooms>2</rooms>
  </item>
  <item>
    <name>0034</name>
    <label>Doe</label>
    <rooms>5</rooms>
  </item>
  <item>
    <name>0021</name>
    <label>Rijdt</label>
    <rooms>1</rooms>
  </item>
</root>

This means that the CSV file can be queried just like an XML document using regular XPath. For example, to count all households with more than 1 room:

<bind nodeset="..." calculate="count(instance('households')/root/item[rooms > 1])" />