Hello ODK Community,
Is it possible to get nth index value from a nodeset?
e.g.
/data/variable[4]
and if we can make it dynamic somehow such as ...
/data/variable[position(..)]
Best,
Ayub
Hello ODK Community,
Is it possible to get nth index value from a nodeset?
e.g.
/data/variable[4]
and if we can make it dynamic somehow such as ...
/data/variable[position(..)]
Best,
Ayub
See selected-at() at https://opendatakit.org/help/form-design/binding/.
Yaw
On Sun, Nov 22, 2015 at 2:26 AM, Ayub nrspaggregate@gmail.com wrote:
Hello ODK Community,
Is it possible to get nth index value from a nodeset?
e.g.
/data/variable[4]
and if we can make it dynamic somehow such as ...
/data/variable[position(..)]
Best,
Ayub--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en
You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Yaw,
I have tried:
calculate="pulldata('clients_hh', 'age', 'key',
selected-at(/data/hhMembers/hhOldId, /data/hhMemInfo/hhMemID))"
calculate="selected-at(/data/hhMembers/ageOld, position(..))"
But both seem to present this error:
https://lh3.googleusercontent.com/-5silhmjZkd0/VlGWBUA1e1I/AAAAAAAAAB0/Gzw_vXtHIVI/s1600/error.png
Little background:
There is a loop earlier than the current repeat (independent/at same
level/not repeat within a repeat) so in the first repeat i have calculated
age from csv file, using pulldata(), that seems to work fine, now i want to
retrieve that age corresponding to each person in calculate (by supplying
either id of the person 1, 2, 3 or position(..)).
Thanks for your input.
Best,
Ayub
It works now, my bad! i wasn't using indexed-repeat().
Thanks Yaw,
Best,
Ayub
Using indexed-repeat() is the easiest way to do this.
You can, however, also use index references.
HOWEVER, the XForms parser we are using (javarosa) does not support the
[n] syntax (e.g., [1]).
/path/to/group[1]/field // does not work
Instead, you MUST use
/path/to/group[position(.)=1]/field // works
The '.' in this formula is not qualified with current() or
instance('name'). This is intentional.
'.' needs to refer to the current set of 'group' nodes, and the constraint
formula (inside the ) then requires that the position() value of that
node be equal to the value n.
ALSO, note that:
position() // does not work
is not supported in the javarosa XForms parser. You must use
position(.) // works
It works now, my bad! i wasn't using indexed-repeat().
Thanks Yaw,
Best,
Ayub--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en
You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com
Thanks Mitch, that was really helpful !