ODK XForms spec proposal: create and update Entities from repeats or groups

We are planning to expand this model to include groups. This will allow creating or updating multiple Entities with a single submission without necessarily using repeats. See also the updated XLSForm proposal.

Glossary

Container: the form definition root, a group, or a repeat.
Entity declaration: a meta/entity block in a container that declares how Entities are affected when the form is finalized.

XForms spec

Any container in a form definition MAY directly include at most one Entity declaration. Nested containers MAY also each directly include at most one Entity declaration.

An entities:saveto binding MUST be associated with the nearest ancestor container that has an Entity declaration. If no ancestor container has an Entity declaration, the form is invalid.

If an entities:saveto binding is declared within a repeat, the nearest ancestor container that has an Entity declaration MUST be that repeat or a descendant group of that repeat. If the nearest ancestor container with an Entity declaration is outside the repeat, the form is invalid.

Examples

  • If a saveto is declared within the group /data/tree and /data/tree has an Entity declaration, the saveto is associated with the Entity declared in /data/tree.
  • If a saveto is declared within the group /data/tree, /data/tree has no Entity declaration, and the root container has an Entity declaration, the saveto is associated with the root Entity declaration.
  • If a saveto is declared within the repeat /data/trees, /data/trees has no Entity declaration, and the root container has an Entity declaration, the form is invalid.
  • If a saveto is declared within the repeat /data/trees/seedlings, /data/trees/seedlings has an Entity declaration, then the saveto is associated with the Entity declared in /data/trees/seedlings, regardless of whether trees is a repeat or group and whether or not it has an Entity declaration.
  • If a saveto is declared within the repeat /data/trees/seedlings, /data/trees/seedlings does not have an Entity declaration, and /data/trees is a group or repeat with an Entity declaration, the form is invalid.
  • If a saveto is declared within the repeat /data/trees/seedlings, /data/trees/seedlings has an Entity declaration, then the saveto is associated with the Entity declaration in /data/trees/seedlings. If another saveto is declared within /data/trees and outside of /data/trees/seedlings and /data/trees has an Entity declaration, then that saveto is associated with the Entity declaration in /data/trees, regardless of whether trees is a repeat or group.