There isn't enough context here to answer your question.
···
----------------
If you need to reference fields within a repeat group, within XLSForm, you
cannot use the ${fieldname} syntax, as it expands to an expression that
refers to all values for that one field, across all repetitions of the
enclosing repeat group(s).
Instead, you must use relative referencing, where you use ../../field2 to
move up two groups to access the value of field2, or, ../../alt2/field3 to
move up two groups, descend into the alt2 group, and select field3 in that
group.
The problem occurs when you want to use these relative references within
cascading select filters, e.g., consider a survey asking for a history of
all towns in which you've ever lived. This would have a repeat group where
you ask the user what state they live in (mystate), and then based upon
that answer, present a list of counties within that state. In the XML,
there would be a relative clause used within the towns cascading select
like:
instance('towns')/state[name=../mystate]/town
Here, the use of ../mystate will not work because the context from which it
starts is the instance('towns')/state context, rather than the form
submission data that you are gathering.
So you need to use current()/ to tell Javarosa to interpret the ../mystate
as referring to the form submission data. I.e.,
instance('towns')/state[name=current()/../mystate]/town
If you want to reference a field (field2) contained in a repeat group
(groupname) at some point later in the form, then the indexed-repeat()
expression can be useful. Here, you can do, e.g.,
indexed-repeat(${field2}, ${groupname}, 3)
Where you retrieve field2 from the 3rd repeat of the repeat group
'groupname' (field2 can be nested arbitrarily deeply within non-repeating
groups within 'groupname'). The nice thing here is that this uses XLS's
${fieldname} syntax.
This supports several layers of repeat-group nestings, so, for example:
indexed-repeat(${item_name}, ${household_members}, 4, ${owned_items}, 2)
would retrieve the name (item_name) of the 2nd item owned by the 4th member
of the household.
On Tue, Jul 15, 2014 at 10:49 AM, Ngamita Richard ngamita@gmail.com wrote:
Hi guys,
I've moved this from community to developers list, but adding additional
information here. I'm currently running with the newest ODK Collect 1.4.3
on Nexus 7 tab and i need help with this error "XPath evaluation: type
mismatch This field is repeated... You may need to use the indexed-repeat()
function to specify which value you want...".
Looking around the mailing list, it seems like the solution is by using
the current()/.. qualifier to an XPath expression. Is this already
supported with XLSForms? Does anyone have an xls file with this example, or
point me to some documentation.
Check out line from repeat group in the test_data.xml file attached.
Richard
--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com