How to display the current index of a repeating field list?

I'm fairly new to xforms, and have looked at
http://opendatakit.org/help/form-design/binding/. Now I am trying to
achieve the following:
I have a repeated group of fields, and in one of the hints, I want to
display the current index of the repetition; for example, like "You are now
entering the 4th product" if he has about to enter the 4th 'instance' of
this repeated group.

My idea was to do it as below, but it doesn't seem to be correct (in the
output, I only see "You are entering the" and nothing afterwards, but also
no exception). Not sure if I'm using the function correctly and at the
right place.
You are entering the .
product

This is my repeating field section in my form:

  <repeat nodeset="/nm/repeatingFieldList" appearance="field-list">
      <label>Product</label> 
PART 1: PRODUCTION STATUS 1.2 Production status details * You are entering the . product* Product reference: Number of closed cartons: Quantity of packed products: Quantity of finished but unpacked products: Quantity of unfinished products:

Hi Mathias,

I think your usage is correct, but this must be a bug in the JavaROSA
library. My guess is that count() isn't implemented properly. Anyway,
I'll forward this on to the javarosa-developers list and try to track
it down. I've filed the bug at
http://code.google.com/p/opendatakit/issues/detail?id=539 for now.

Yaw

··· On Sat, Mar 17, 2012 at 20:49, Mathias Lin wrote: > I'm fairly new to xforms, and have looked at > http://opendatakit.org/help/form-design/binding/. Now I am trying to achieve > the following: > I have a repeated group of fields, and in one of the hints, I want to > display the current index of the repetition; for example, like "You are now > entering the 4th product" if he has about to enter the 4th 'instance' of > this repeated group. > > My idea was to do it as below, but it doesn't seem to be correct (in the > output, I only see "You are entering the" and nothing afterwards, but also > no exception). Not sure if I'm using the function correctly and at the right > place. > You are entering the . > product > > This is my repeating field section in my form: > > > Product > > PART 1: PRODUCTION STATUS > > 1.2 Production status details > You are entering the . > product > > > Product reference: > > > Number of closed cartons: > > > Quantity of packed products: > > > Quantity of finished but unpacked products: > > > Quantity of unfinished products: > > > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en

Hi Yaw,

thanks for the reply and filing the bug report.

Actually I saw that I made one mistake, which results to a different
output, however, there still seems to be a bug with the count.

First, my correction: there should be a /repeatingFieldList in the path.

You are entering the . product

This leads then to an output of:
*"You are entering the 1. product" *
but remains at 1, even I'm already entering the second or third instance
of it. It seems that the count() doesn't work properly/can't be used with a
variable that refers to itself (meaning: while I'm in repeatingFieldList, I
can't use count on any field within repeatingFieldList).

However, when I refer to a different variable in the count method, for
example to a previous repeating field list (not the current one), I'm
getting the correct (final) number of instances of that repeated field list.

On the other hand, the counter (but I guess it's not using the count()
method of xforms here) in the 'breadcrumb path' that's automatically
displayed by ODK is fine.

See the following screenshot (the second red-marked number should also be a
3, but it's always showing a 1):

(I will add this finding to the bug report).

  • Mathias
··· On Sun, Mar 18, 2012 at 1:29 PM, Yaw Anokwa wrote:

Hi Mathias,

I think your usage is correct, but this must be a bug in the JavaROSA
library. My guess is that count() isn't implemented properly. Anyway,
I'll forward this on to the javarosa-developers list and try to track
it down. I've filed the bug at
http://code.google.com/p/opendatakit/issues/detail?id=539 for now.

Yaw

On Sat, Mar 17, 2012 at 20:49, Mathias Lin mathias.conradt@gmail.com wrote:

I'm fairly new to xforms, and have looked at
http://opendatakit.org/help/form-design/binding/. Now I am trying to
achieve
the following:
I have a repeated group of fields, and in one of the hints, I want to
display the current index of the repetition; for example, like "You are
now
entering the 4th product" if he has about to enter the 4th 'instance' of
this repeated group.

My idea was to do it as below, but it doesn't seem to be correct (in the
output, I only see "You are entering the" and nothing afterwards, but
also
no exception). Not sure if I'm using the function correctly and at the
right
place.
You are entering the .
product

This is my repeating field section in my form:

  <repeat nodeset="/nm/repeatingFieldList" appearance="field-list">
      <label>Product</label>
PART 1: PRODUCTION STATUS 1.2 Production status details You are entering the . product Product reference: Number of closed cartons: Quantity of packed products: Quantity of finished but unpacked products: Quantity of unfinished products:

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Mathias,

The reason this is occurring is because in JR, the evaluation context for
relative references inside a repeat is evaluated against the current
nodeset (inside the repeat). This is necessary for constructs like

The answer to the previous question was

to work correctly.

count() in this context would also only return the correct value for the
last element. The xpath function which does the best thing here is
position(), which is supported in the newest code for JR, which is
currently staged and working at our fork (
http://bitbucket.org/commcare/javarosa), and will be pushed back into the
core JR libraries soon.

-Clayton

··· On Sun, Mar 18, 2012 at 3:27 AM, Mathias Lin wrote:

Hi Yaw,

thanks for the reply and filing the bug report.

Actually I saw that I made one mistake, which results to a different
output, however, there still seems to be a bug with the count.

First, my correction: there should be a /repeatingFieldList in the path.

You are entering the . product

This leads then to an output of:
*"You are entering the 1. product" *
but remains at 1, even I'm already entering the second or third
instance of it. It seems that the count() doesn't work properly/can't be
used with a variable that refers to itself (meaning: while I'm in
repeatingFieldList, I can't use count on any field within
repeatingFieldList).

However, when I refer to a different variable in the count method, for
example to a previous repeating field list (not the current one), I'm
getting the correct (final) number of instances of that repeated field list.

On the other hand, the counter (but I guess it's not using the count()
method of xforms here) in the 'breadcrumb path' that's automatically
displayed by ODK is fine.

See the following screenshot (the second red-marked number should also be
a 3, but it's always showing a 1):

http://imageshack.us/photo/my-images/838/odkrepeat.png/

(I will add this finding to the bug report).

  • Mathias

On Sun, Mar 18, 2012 at 1:29 PM, Yaw Anokwa yanokwa@gmail.com wrote:

Hi Mathias,

I think your usage is correct, but this must be a bug in the JavaROSA
library. My guess is that count() isn't implemented properly. Anyway,
I'll forward this on to the javarosa-developers list and try to track
it down. I've filed the bug at
http://code.google.com/p/opendatakit/issues/detail?id=539 for now.

Yaw

On Sat, Mar 17, 2012 at 20:49, Mathias Lin mathias.conradt@gmail.com wrote:

I'm fairly new to xforms, and have looked at
http://opendatakit.org/help/form-design/binding/. Now I am trying to
achieve
the following:
I have a repeated group of fields, and in one of the hints, I want to
display the current index of the repetition; for example, like "You are
now
entering the 4th product" if he has about to enter the 4th 'instance' of
this repeated group.

My idea was to do it as below, but it doesn't seem to be correct (in the
output, I only see "You are entering the" and nothing afterwards, but
also
no exception). Not sure if I'm using the function correctly and at the
right
place.
You are entering the .
product

This is my repeating field section in my form:

  <repeat nodeset="/nm/repeatingFieldList" appearance="field-list">
      <label>Product</label>
PART 1: PRODUCTION STATUS 1.2 Production status details You are entering the <output

value="count(/nm/output1_2)"/>.

product


Product reference:


Number of closed cartons:


Quantity of packed products:


Quantity of finished but unpacked products:


Quantity of unfinished products:


--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Mathais,

Another option is to use "new-style" repeats that are in the JavaROSA,
but have not been enabled in Collect UI. Those repeats should enable
you reference the variables $i and $n for the current index and total

of repetitions, respectively. Drew from Dimagi is the expert on

this, so you can follow up with him at
https://groups.google.com/group/javarosa-developers/browse_thread/thread/1e1e3681580a407a.

It shouldn't be too much work to turn them on, and the addition would
be a nice win for the ODK community.

Yaw

··· On Mon, Mar 19, 2012 at 08:10, Clayton Sims wrote: > Mathias, > > The reason this is occurring is because in JR, the evaluation context for > relative references inside a repeat is evaluated against the current nodeset > (inside the repeat). This is necessary for constructs like > > The answer to the previous question was value="count(/nm/repeatingFieldList/previous)"/> > > to work correctly. > > count() in this context would also only return the correct value for the > last element. The xpath function which does the best thing here > is position(), which is supported in the newest code for JR, which is > currently staged and working at our fork > (http://bitbucket.org/commcare/javarosa), and will be pushed back into the > core JR libraries soon. > > -Clayton > > > On Sun, Mar 18, 2012 at 3:27 AM, Mathias Lin wrote: >> >> Hi Yaw, >> >> thanks for the reply and filing the bug report. >> >> Actually I saw that I made one mistake, which results to a different >> output, however, there still seems to be a bug with the count. >> >> First, my correction: there should be a /repeatingFieldList in the path. >> >> You are entering the > value="count(/nm/repeatingFieldList/output1_2)"/>. product >> >> This leads then to an output of: >> "You are entering the 1. product" >> but remains at 1, even I'm already entering the second or third instance >> of it. It seems that the count() doesn't work properly/can't be used with a >> variable that refers to itself (meaning: while I'm in repeatingFieldList, I >> can't use count on any field within repeatingFieldList). >> >> However, when I refer to a different variable in the count method, for >> example to a previous repeating field list (not the current one), I'm >> getting the correct (final) number of instances of that repeated field list. >> >> On the other hand, the counter (but I guess it's not using the count() >> method of xforms here) in the 'breadcrumb path' that's automatically >> displayed by ODK is fine. >> >> See the following screenshot (the second red-marked number should also be >> a 3, but it's always showing a 1): >> >> http://imageshack.us/photo/my-images/838/odkrepeat.png/ >> >> (I will add this finding to the bug report). >> >> - Mathias >> >> >> On Sun, Mar 18, 2012 at 1:29 PM, Yaw Anokwa wrote: >>> >>> Hi Mathias, >>> >>> I think your usage is correct, but this must be a bug in the JavaROSA >>> library. My guess is that count() isn't implemented properly. Anyway, >>> I'll forward this on to the javarosa-developers list and try to track >>> it down. I've filed the bug at >>> http://code.google.com/p/opendatakit/issues/detail?id=539 for now. >>> >>> Yaw >>> >>> On Sat, Mar 17, 2012 at 20:49, Mathias Lin wrote: >>> > I'm fairly new to xforms, and have looked at >>> > http://opendatakit.org/help/form-design/binding/. Now I am trying to >>> > achieve >>> > the following: >>> > I have a repeated group of fields, and in one of the hints, I want to >>> > display the current index of the repetition; for example, like "You are >>> > now >>> > entering the 4th product" if he has about to enter the 4th 'instance' >>> > of >>> > this repeated group. >>> > >>> > My idea was to do it as below, but it doesn't seem to be correct (in >>> > the >>> > output, I only see "You are entering the" and nothing afterwards, but >>> > also >>> > no exception). Not sure if I'm using the function correctly and at the >>> > right >>> > place. >>> > You are entering the . >>> > product >>> > >>> > This is my repeating field section in my form: >>> > >>> > >>> > Product >>> > >>> > PART 1: PRODUCTION STATUS >>> > >>> > 1.2 Production status details >>> > You are entering the >> > value="count(/nm/output1_2)"/>. >>> > product >>> > >>> > >>> > Product reference: >>> > >>> > >>> > Number of closed cartons: >>> > >>> > >>> > Quantity of packed products: >>> > >>> > >>> > Quantity of finished but unpacked products: >>> > >>> > >>> > Quantity of unfinished products: >>> > >>> > >>> > >>> > >>> > -- >>> > Post: opendatakit@googlegroups.com >>> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >>> > Options: http://groups.google.com/group/opendatakit?hl=en >>> >>> -- >>> Post: opendatakit@googlegroups.com >>> Unsubscribe: opendatakit+unsubscribe@googlegroups.com >>> Options: http://groups.google.com/group/opendatakit?hl=en >> >> >> -- >> Post: opendatakit@googlegroups.com >> Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> Options: http://groups.google.com/group/opendatakit?hl=en > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en

Dear Yaw
Could I refer to value of variable when i'm outside of repeats in the next release of Collect? Could you estimate the time for the next release (I read from another topic that this function will include in Collect 1.1.7 but I haven't seen it)?
I'm doing a household research and we need to call out the index number of member in household from outside of repeats to enter more details.

Thank you
Quang
Vào 02:33:27 UTC+7 Thứ bảy, ngày 24 tháng ba năm 2012, Yaw Anokwa đã viết:

··· > Mathais, > > Another option is to use "new-style" repeats that are in the JavaROSA, > but have not been enabled in Collect UI. Those repeats should enable > you reference the variables $i and $n for the current index and total > # of repetitions, respectively. Drew from Dimagi is the expert on > this, so you can follow up with him at > https://groups.google.com/group/javarosa-developers/browse_thread/thread/1e1e3681580a407a. > > It shouldn't be too much work to turn them on, and the addition would > be a nice win for the ODK community. > > Yaw > > On Mon, Mar 19, 2012 at 08:10, Clayton Sims wrote: > > Mathias, > > > > The reason this is occurring is because in JR, the evaluation context for > > relative references inside a repeat is evaluated against the current nodeset > > (inside the repeat). This is necessary for constructs like > > > > The answer to the previous question was > value="count(/nm/repeatingFieldList/previous)"/> > > > > to work correctly. > > > > count() in this context would also only return the correct value for the > > last element. The xpath function which does the best thing here > > is position(), which is supported in the newest code for JR, which is > > currently staged and working at our fork > > (http://bitbucket.org/commcare/javarosa), and will be pushed back into the > > core JR libraries soon. > > > > -Clayton > > > > > > On Sun, Mar 18, 2012 at 3:27 AM, Mathias Lin wrote: > >> > >> Hi Yaw, > >> > >> thanks for the reply and filing the bug report. > >> > >> Actually I saw that I made one mistake, which results to a different > >> output, however, there still seems to be a bug with the count. > >> > >> First, my correction: there should be a /repeatingFieldList in the path. > >> > >> You are entering the >> value="count(/nm/repeatingFieldList/output1_2)"/>. product > >> > >> This leads then to an output of: > >> "You are entering the 1. product" > >> but remains at 1, even I'm already entering the second or third instance > >> of it. It seems that the count() doesn't work properly/can't be used with a > >> variable that refers to itself (meaning: while I'm in repeatingFieldList, I > >> can't use count on any field within repeatingFieldList). > >> > >> However, when I refer to a different variable in the count method, for > >> example to a previous repeating field list (not the current one), I'm > >> getting the correct (final) number of instances of that repeated field list. > >> > >> On the other hand, the counter (but I guess it's not using the count() > >> method of xforms here) in the 'breadcrumb path' that's automatically > >> displayed by ODK is fine. > >> > >> See the following screenshot (the second red-marked number should also be > >> a 3, but it's always showing a 1): > >> > >> http://imageshack.us/photo/my-images/838/odkrepeat.png/ > >> > >> (I will add this finding to the bug report). > >> > >> - Mathias > >> > >> > >> On Sun, Mar 18, 2012 at 1:29 PM, Yaw Anokwa wrote: > >>> > >>> Hi Mathias, > >>> > >>> I think your usage is correct, but this must be a bug in the JavaROSA > >>> library. My guess is that count() isn't implemented properly. Anyway, > >>> I'll forward this on to the javarosa-developers list and try to track > >>> it down. I've filed the bug at > >>> http://code.google.com/p/opendatakit/issues/detail?id=539 for now. > >>> > >>> Yaw > >>> > >>> On Sat, Mar 17, 2012 at 20:49, Mathias Lin wrote: > >>> > I'm fairly new to xforms, and have looked at > >>> > http://opendatakit.org/help/form-design/binding/. Now I am trying to > >>> > achieve > >>> > the following: > >>> > I have a repeated group of fields, and in one of the hints, I want to > >>> > display the current index of the repetition; for example, like "You are > >>> > now > >>> > entering the 4th product" if he has about to enter the 4th 'instance' > >>> > of > >>> > this repeated group. > >>> > > >>> > My idea was to do it as below, but it doesn't seem to be correct (in > >>> > the > >>> > output, I only see "You are entering the" and nothing afterwards, but > >>> > also > >>> > no exception). Not sure if I'm using the function correctly and at the > >>> > right > >>> > place. > >>> > You are entering the . > >>> > product > >>> > > >>> > This is my repeating field section in my form: > >>> > > >>> > > >>> > Product > >>> > > >>> > PART 1: PRODUCTION STATUS > >>> > > >>> > 1.2 Production status details > >>> > You are entering the >>> > value="count(/nm/output1_2)"/>. > >>> > product > >>> > > >>> > > >>> > Product reference: > >>> > > >>> > > >>> > Number of closed cartons: > >>> > > >>> > > >>> > Quantity of packed products: > >>> > > >>> > > >>> > Quantity of finished but unpacked products: > >>> > > >>> > > >>> > Quantity of unfinished products: > >>> > > >>> > > >>> > > >>> > > >>> > -- > >>> > Post: opendatakit@googlegroups.com > >>> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > >>> > Options: http://groups.google.com/group/opendatakit?hl=en > >>> > >>> -- > >>> Post: opendatakit@googlegroups.com > >>> Unsubscribe: opendatakit+unsubscribe@googlegroups.com > >>> Options: http://groups.google.com/group/opendatakit?hl=en > >> > >> > >> -- > >> Post: opendatakit@googlegroups.com > >> Unsubscribe: opendatakit+unsubscribe@googlegroups.com > >> Options: http://groups.google.com/group/opendatakit?hl=en > > > > > > -- > > Post: opendatakit@googlegroups.com > > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en

New style repeats didn't make the cut for 1.1.7, and it's unlikely
they'll make the cut for the next release unless a community member
adds it.

Don't know about referring to values outside a repeat. I've asked Drew
at https://groups.google.com/group/javarosa-developers/browse_thread/thread/1e1e3681580a407a.

··· On Wed, Mar 28, 2012 at 11:30, wrote: > Dear Yaw > Could I refer to value of variable when i'm outside of repeats in the next release of Collect? Could you estimate the time for the next release (I read from another topic that this function will include in Collect 1.1.7 but I haven't seen it)? > I'm doing a household research and we need to call out the index number of member in household from outside of repeats to enter more details. > > Thank you > Quang > Vào 02:33:27 UTC+7 Thứ bảy, ngày 24 tháng ba năm 2012, Yaw Anokwa đã viết: >> Mathais, >> >> Another option is to use "new-style" repeats that are in the JavaROSA, >> but have not been enabled in Collect UI. Those repeats should enable >> you reference the variables $i and $n for the current index and total >> # of repetitions, respectively. Drew from Dimagi is the expert on >> this, so you can follow up with him at >> https://groups.google.com/group/javarosa-developers/browse_thread/thread/1e1e3681580a407a. >> >> It shouldn't be too much work to turn them on, and the addition would >> be a nice win for the ODK community. >> >> Yaw >> >> On Mon, Mar 19, 2012 at 08:10, Clayton Sims wrote: >> > Mathias, >> > >> > The reason this is occurring is because in JR, the evaluation context for >> > relative references inside a repeat is evaluated against the current nodeset >> > (inside the repeat). This is necessary for constructs like >> > >> > The answer to the previous question was > > value="count(/nm/repeatingFieldList/previous)"/> >> > >> > to work correctly. >> > >> > count() in this context would also only return the correct value for the >> > last element. The xpath function which does the best thing here >> > is position(), which is supported in the newest code for JR, which is >> > currently staged and working at our fork >> > (http://bitbucket.org/commcare/javarosa), and will be pushed back into the >> > core JR libraries soon. >> > >> > -Clayton >> > >> > >> > On Sun, Mar 18, 2012 at 3:27 AM, Mathias Lin wrote: >> >> >> >> Hi Yaw, >> >> >> >> thanks for the reply and filing the bug report. >> >> >> >> Actually I saw that I made one mistake, which results to a different >> >> output, however, there still seems to be a bug with the count. >> >> >> >> First, my correction: there should be a /repeatingFieldList in the path. >> >> >> >> You are entering the > >> value="count(/nm/repeatingFieldList/output1_2)"/>. product >> >> >> >> This leads then to an output of: >> >> "You are entering the 1. product" >> >> but remains at 1, even I'm already entering the second or third instance >> >> of it. It seems that the count() doesn't work properly/can't be used with a >> >> variable that refers to itself (meaning: while I'm in repeatingFieldList, I >> >> can't use count on any field within repeatingFieldList). >> >> >> >> However, when I refer to a different variable in the count method, for >> >> example to a previous repeating field list (not the current one), I'm >> >> getting the correct (final) number of instances of that repeated field list. >> >> >> >> On the other hand, the counter (but I guess it's not using the count() >> >> method of xforms here) in the 'breadcrumb path' that's automatically >> >> displayed by ODK is fine. >> >> >> >> See the following screenshot (the second red-marked number should also be >> >> a 3, but it's always showing a 1): >> >> >> >> http://imageshack.us/photo/my-images/838/odkrepeat.png/ >> >> >> >> (I will add this finding to the bug report). >> >> >> >> - Mathias >> >> >> >> >> >> On Sun, Mar 18, 2012 at 1:29 PM, Yaw Anokwa wrote: >> >>> >> >>> Hi Mathias, >> >>> >> >>> I think your usage is correct, but this must be a bug in the JavaROSA >> >>> library. My guess is that count() isn't implemented properly. Anyway, >> >>> I'll forward this on to the javarosa-developers list and try to track >> >>> it down. I've filed the bug at >> >>> http://code.google.com/p/opendatakit/issues/detail?id=539 for now. >> >>> >> >>> Yaw >> >>> >> >>> On Sat, Mar 17, 2012 at 20:49, Mathias Lin wrote: >> >>> > I'm fairly new to xforms, and have looked at >> >>> > http://opendatakit.org/help/form-design/binding/. Now I am trying to >> >>> > achieve >> >>> > the following: >> >>> > I have a repeated group of fields, and in one of the hints, I want to >> >>> > display the current index of the repetition; for example, like "You are >> >>> > now >> >>> > entering the 4th product" if he has about to enter the 4th 'instance' >> >>> > of >> >>> > this repeated group. >> >>> > >> >>> > My idea was to do it as below, but it doesn't seem to be correct (in >> >>> > the >> >>> > output, I only see "You are entering the" and nothing afterwards, but >> >>> > also >> >>> > no exception). Not sure if I'm using the function correctly and at the >> >>> > right >> >>> > place. >> >>> > You are entering the . >> >>> > product >> >>> > >> >>> > This is my repeating field section in my form: >> >>> > >> >>> > >> >>> > Product >> >>> > >> >>> > PART 1: PRODUCTION STATUS >> >>> > >> >>> > 1.2 Production status details >> >>> > You are entering the > >>> > value="count(/nm/output1_2)"/>. >> >>> > product >> >>> > >> >>> > >> >>> > Product reference: >> >>> > >> >>> > >> >>> > Number of closed cartons: >> >>> > >> >>> > >> >>> > Quantity of packed products: >> >>> > >> >>> > >> >>> > Quantity of finished but unpacked products: >> >>> > >> >>> > >> >>> > Quantity of unfinished products: >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > -- >> >>> > Post: opendatakit@googlegroups.com >> >>> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >>> > Options: http://groups.google.com/group/opendatakit?hl=en >> >>> >> >>> -- >> >>> Post: opendatakit@googlegroups.com >> >>> Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >>> Options: http://groups.google.com/group/opendatakit?hl=en >> >> >> >> >> >> -- >> >> Post: opendatakit@googlegroups.com >> >> Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >> Options: http://groups.google.com/group/opendatakit?hl=en >> > >> > >> > -- >> > Post: opendatakit@googlegroups.com >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> > Options: http://groups.google.com/group/opendatakit?hl=en > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en

Referring to values outside of a repeat is currently in the core code base
along with predicate support. We still need to plan out the integration of
the new core code into ODK Collect.

-Clayton

··· On Wed, Mar 28, 2012 at 7:57 PM, Yaw Anokwa wrote:

New style repeats didn't make the cut for 1.1.7, and it's unlikely
they'll make the cut for the next release unless a community member
adds it.

Don't know about referring to values outside a repeat. I've asked Drew
at
https://groups.google.com/group/javarosa-developers/browse_thread/thread/1e1e3681580a407a
.

On Wed, Mar 28, 2012 at 11:30, thq@hsph.edu.vn wrote:

Dear Yaw
Could I refer to value of variable when i'm outside of repeats in the
next release of Collect? Could you estimate the time for the next release
(I read from another topic that this function will include in Collect 1.1.7
but I haven't seen it)?
I'm doing a household research and we need to call out the index number
of member in household from outside of repeats to enter more details.

Thank you
Quang
Vào 02:33:27 UTC+7 Thứ bảy, ngày 24 tháng ba năm 2012, Yaw Anokwa đã
viết:

Mathais,

Another option is to use "new-style" repeats that are in the JavaROSA,
but have not been enabled in Collect UI. Those repeats should enable
you reference the variables $i and $n for the current index and total

of repetitions, respectively. Drew from Dimagi is the expert on

this, so you can follow up with him at

https://groups.google.com/group/javarosa-developers/browse_thread/thread/1e1e3681580a407a
.

It shouldn't be too much work to turn them on, and the addition would
be a nice win for the ODK community.

Yaw

On Mon, Mar 19, 2012 at 08:10, Clayton Sims csims@dimagi.com wrote:

Mathias,

The reason this is occurring is because in JR, the evaluation context
for

relative references inside a repeat is evaluated against the current
nodeset

(inside the repeat). This is necessary for constructs like

The answer to the previous question was

to work correctly.

count() in this context would also only return the correct value for
the

last element. The xpath function which does the best thing here
is position(), which is supported in the newest code for JR, which is
currently staged and working at our fork
(http://bitbucket.org/commcare/javarosa), and will be pushed back
into the

core JR libraries soon.

-Clayton

On Sun, Mar 18, 2012 at 3:27 AM, Mathias Lin < mathias.conradt@gmail.com> wrote:

Hi Yaw,

thanks for the reply and filing the bug report.

Actually I saw that I made one mistake, which results to a different
output, however, there still seems to be a bug with the count.

First, my correction: there should be a /repeatingFieldList in the
path.

You are entering the . product

This leads then to an output of:
"You are entering the 1. product"
but remains at 1, even I'm already entering the second or third
instance

of it. It seems that the count() doesn't work properly/can't be used
with a

variable that refers to itself (meaning: while I'm in
repeatingFieldList, I

can't use count on any field within repeatingFieldList).

However, when I refer to a different variable in the count method,
for

example to a previous repeating field list (not the current one), I'm
getting the correct (final) number of instances of that repeated
field list.

On the other hand, the counter (but I guess it's not using the
count()

method of xforms here) in the 'breadcrumb path' that's automatically
displayed by ODK is fine.

See the following screenshot (the second red-marked number should
also be

a 3, but it's always showing a 1):

http://imageshack.us/photo/my-images/838/odkrepeat.png/

(I will add this finding to the bug report).

  • Mathias

On Sun, Mar 18, 2012 at 1:29 PM, Yaw Anokwa yanokwa@gmail.com wrote:

Hi Mathias,

I think your usage is correct, but this must be a bug in the
JavaROSA

library. My guess is that count() isn't implemented properly.
Anyway,

I'll forward this on to the javarosa-developers list and try to
track

it down. I've filed the bug at
http://code.google.com/p/opendatakit/issues/detail?id=539 for now.

Yaw

On Sat, Mar 17, 2012 at 20:49, Mathias Lin < mathias.conradt@gmail.com> wrote:

I'm fairly new to xforms, and have looked at
http://opendatakit.org/help/form-design/binding/. Now I am
trying to

achieve
the following:
I have a repeated group of fields, and in one of the hints, I
want to

display the current index of the repetition; for example, like
"You are

now
entering the 4th product" if he has about to enter the 4th
'instance'

of
this repeated group.

My idea was to do it as below, but it doesn't seem to be correct
(in

the
output, I only see "You are entering the" and nothing afterwards,
but

also
no exception). Not sure if I'm using the function correctly and
at the

right
place.
You are entering the .
product

This is my repeating field section in my form:

  <repeat nodeset="/nm/repeatingFieldList"

appearance="field-list">

      <label>Product</label>
PART 1: PRODUCTION STATUS 1.2 Production status details You are entering the . product Product reference: Number of closed cartons: Quantity of packed products: Quantity of finished but unpacked products: Quantity of unfinished products:

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en