A question about referencing using " ../field " versus " ${field} "

Hi there,

I wonder if you have experience using “ ../field “ ? I don’t quite
understand the difference between ../ versus ${}, but it seems that I have
to change a few referencing from ${field} to ../field in some repeat
groups of my form, otherwise the second repeat group will crash. I couldn't
find a common rule of what exact situation that I have to do ../ .

On ODK Binding, it has the descriptions of the two here
https://opendatakit.org/help/form-design/binding/
https://opendatakit.org/help/form-design/binding/ but I don’t quite get
it. Could anyone please clarify this please?

Thank you very much.

E

Hi Eva,

The ../node or /path/to/node "XPath" syntax is what ODK Collect and Enketo
actually use internally (they render XForms not XLSForms). The relative
path "../node" means that from the current field you go one step back and
find a field with the name "node". You can read more about the actual XForm
format that is supported here: http://opendatakit.github.io/odk-xform-spec/.

Even for die-hard XML and XPath enthusiasts (if they exist), coding an
XForm by hand is very tedious. That's why we are lucky to have XLSForms,
that will translate and easy-to-build XLSForm into an XForm. One of the
shortcuts is the ${field} syntax which currently always translates to an
absolute "/path/to/field" (though XLSForm also supports the XPath syntax).

At some point, a long time ago, a rather unfortunate error was made with how
repeats should be handled
http://opendatakit.github.io/odk-xform-spec/#a-big-deviation-with-xforms.
We are working around this in ODK Collect and Enketo, but you are probably
dealing with an artefact of this issue, and found a way to resolve it by
using the correct relative XPath syntax instead of the ${field} shortcut
when referring to fields inside a repeat.

If you are referring to a field that is at the same level as the field
where you are referring from you'd use "../field" instead of ${field}. If
you are inside a group and are referring to a field just outside that
group, you could use "../../field" instead of ${field}. Etcetera.

Cheers,
Martijn

··· On Tuesday, April 21, 2015 at 1:27:21 PM UTC-6, Eva Q wrote: > > Hi there, > > > > I wonder if you have experience using “ ../field “ ? I don’t quite > understand the difference between ../ versus ${}, but it seems that I have > to change a few referencing from ${field} to ../field in some repeat > groups of my form, otherwise the second repeat group will crash. I couldn't > find a common rule of what exact situation that I have to do ../ . > > On ODK Binding, it has the descriptions of the two here > *https://opendatakit.org/help/form-design/binding/* > but I don’t quite get > it. Could anyone please clarify this please? > > > > Thank you very much. > > E >

--

Revolutionizing data collection since 2012.

Enketo https://enketo.org/ | LinkedIn
http://www.linkedin.com/company/enketo-llc | GitHub
https://github.com/enketo | Twitter https://twitter.com/enketo
| Blog http://blog.enketo.org/