Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support external secondary XML instances #275

Closed
MartijnR opened this issue Nov 29, 2016 · 4 comments
Closed

Support external secondary XML instances #275

MartijnR opened this issue Nov 29, 2016 · 4 comments

Comments

@MartijnR
Copy link
Contributor

MartijnR commented Nov 29, 2016

Like CommCare and Enketo.

Instead of an internal secondary instance:

<instance>
    <countries>
         <country>
               <name>Mexico</name>
         <country>
         ...
    </countries>
</instance>

You could use a (dynamic or static) external secondary instance published in the XForms manifest:

<instance src="jr://file/countries.xml" />

This instance can be queried just like with an 'internal' secondary instance in any XPath expression (contraints, calculations, relevants, requireds, itemsets).

Test XForm
Test External data files

(as a follow-up we could extend this feature by also supporting CSV files but better covered as a separate issue).

@MartijnR MartijnR changed the title Support external secondary XML instances (like CommCare) Support external secondary XML instances Nov 29, 2016
@yanokwa
Copy link
Member

yanokwa commented Dec 5, 2016

@MartijnR We want to make sure issues that are filed are not just a proposed solution, but also a good explanation of what the core problem is and why it matters. This way, we can have a grounded discussion about the implementation.

So with that in mind, why do people need this feature and what does it enable? Example scenarios from Enketo and CommCare would help!

@MartijnR
Copy link
Contributor Author

MartijnR commented Dec 6, 2016

The core problem for ODK Collect would be the inability to add external data that can be used anywhere in any XPath expression. Currently, only a few specific use cases are supported (with CSV files) and those involve a fair bit of magic (ie. the file is magically available, as there is no reference to it in the XForm), are inflexible, and unnecessarily deviate from XForms.

This feature would explode the potential uses of external data by allowing one to query an external data file with regular XPath predicates. For example, if the external data file is a list of camps and households (from a previous survey) and you'd like to:

  • find out how many households there are in a particular camp count(instance(“households”)/camp[@name=“Gerihun”]/household)
  • what the sum of all household members is in a particular camp sum(instance(“households”)/camp[@name=“Gereida”]/household/members)
  • display the names of all household members join(", ", instance("households")//household[@id=abc]/member/name)

There are no limitations on how this can be used, and there is no magic. An external secondary instance is the same as an internal secondary instance from the XPath evaluator's point of view, which is why it's so powerful.

CommCare is using external data to extend XForms with XML documents that have their own specifications, such as session variables (to replace pre-load items), cases, fixtures, ledgers. Some info here. Pinging @ctsims in case he would like to add info.

In addition to the immediate power gained, this can be seen as a 1st step to build future features upon such as:

  1. CSV support, with the same query power
  2. After previous item: fast itemsets for multi-select questions
  3. XPath functions to facilitate easier querying (that simply translate into complex XPath queries)
  4. Domain-specific extensions (custom ports)

@ctsims
Copy link
Contributor

ctsims commented Dec 12, 2016 via email

@lognaturel
Copy link
Member

Closed in getodk/xforms-spec#50 and with @dcbriccetti's ongoing work at getodk/javarosa#16!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants