Conitional Logic on a select1 Question

Dear all,
I am creating a household survey which then has a sub-survey (read question
grouping) which is only relevant to female members within the household if
they are under the age of 49. My thinking was to create a "eligible" flag
against each household member which would be a select1 type question, but
it should be read-only and should default to 'yes' if the person is female
and below the age of 49 or default to 'no' if the person is not female or
above the age of 49. Then the number/count of these 'eligible' individuals
will be the basis for the jr:count value which defines how many times the
group of questions that are meant for women under the age of 49 within the
household should be repeated (i.e if there are 2 eligible women, then the
repeat group for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and 

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at
org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)
at org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)
at org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)
at org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)
at org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
at org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
...
...
Could anyone let me know what I could be doing wrong? Would also be great
if I could know how this could be implemented via xlsforms. Am attaching
the whole xml file as reference.

Thanks in advance,
Tumaini

xls_form_test.xml (7.89 KB)

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read question
grouping) which is only relevant to female members within the household if
they are under the age of 49. My thinking was to create a "eligible" flag
against each household member which would be a select1 type question, but it
should be read-only and should default to 'yes' if the person is female and
below the age of 49 or default to 'no' if the person is not female or above
the age of 49. Then the number/count of these 'eligible' individuals will be
the basis for the jr:count value which defines how many times the group of
questions that are meant for women under the age of 49 within the household
should be repeated (i.e if there are 2 eligible women, then the repeat group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at
org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)
at org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)
at org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)
at org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)
at org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
at org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
...
...
Could anyone let me know what I could be doing wrong? Would also be great
if I could know how this could be implemented via xlsforms. Am attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

Thanks Yaw, I will have a look and modify!

Have a great new years !

··· On 30 Dec 2013 15:36, "Yaw Anokwa" wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read
question
grouping) which is only relevant to female members within the household
if
they are under the age of 49. My thinking was to create a "eligible" flag
against each household member which would be a select1 type question,
but it
should be read-only and should default to 'yes' if the person is female
and
below the age of 49 or default to 'no' if the person is not female or
above
the age of 49. Then the number/count of these 'eligible' individuals
will be
the basis for the jr:count value which defines how many times the group
of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the repeat
group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)

at org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)
at org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
...
...
Could anyone let me know what I could be doing wrong? Would also be
great
if I could know how this could be implemented via xlsforms. Am attaching
the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

--

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/groups/opt_out.

Hello Yaw,
Thanks, that did the trick! I do have another add-on question though... As
mentioned earlier, I want to go into a household and

  1. Register all the household members
  2. Then for each *eligible *member ( 14 < age < 49 and gender = FEMALE), I
    want to ask a series of related questions.

Is it possible within the loop to display the name (or any other attribute)
of the eligible person as captured during step 1, the registration phase?

Thanks in advance,
Tumaini

··· On Mon, Dec 30, 2013 at 8:15 PM, Tumaini Kilimba wrote:

Thanks Yaw, I will have a look and modify!

Have a great new years !
On 30 Dec 2013 15:36, "Yaw Anokwa" yanokwa@nafundi.com wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read
question
grouping) which is only relevant to female members within the household
if
they are under the age of 49. My thinking was to create a "eligible"
flag
against each household member which would be a select1 type question,
but it
should be read-only and should default to 'yes' if the person is female
and
below the age of 49 or default to 'no' if the person is not female or
above
the age of 49. Then the number/count of these 'eligible' individuals
will be
the basis for the jr:count value which defines how many times the group
of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the repeat
group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)

at org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)
at org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
...
...
Could anyone let me know what I could be doing wrong? Would also be
great
if I could know how this could be implemented via xlsforms. Am
attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

--

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/groups/opt_out.

Yes. You can refer to items inside a repeat. See indexed-repeat at
http://opendatakit.org/help/form-design/binding/.

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Mon, Jan 6, 2014 at 12:11 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw,
Thanks, that did the trick! I do have another add-on question though... As
mentioned earlier, I want to go into a household and

  1. Register all the household members
  2. Then for each eligible member ( 14 < age < 49 and gender = FEMALE), I
    want to ask a series of related questions.

Is it possible within the loop to display the name (or any other attribute)
of the eligible person as captured during step 1, the registration phase?

Thanks in advance,
Tumaini

On Mon, Dec 30, 2013 at 8:15 PM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Thanks Yaw, I will have a look and modify!

Have a great new years !

On 30 Dec 2013 15:36, "Yaw Anokwa" yanokwa@nafundi.com wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read
question
grouping) which is only relevant to female members within the household
if
they are under the age of 49. My thinking was to create a "eligible"
flag
against each household member which would be a select1 type question,
but it
should be read-only and should default to 'yes' if the person is female
and
below the age of 49 or default to 'no' if the person is not female or
above
the age of 49. Then the number/count of these 'eligible' individuals
will be
the basis for the jr:count value which defines how many times the group
of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the repeat
group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)
at
org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at
org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)
at org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
at
org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
...
...
Could anyone let me know what I could be doing wrong? Would also be
great
if I could know how this could be implemented via xlsforms. Am
attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

Hello Yaw, I have had a read, but I am not sure whether it will do what I
need. Quoted below from the link you sent:

References the field of the n-th repeat of a group. Groups and indices for
1 to 3 nested repeats can be specified. For example, the XLSForm calculate
expression "indexed-repeat(${name}, ${names}, 1)" will return the value of
the first "name" field inside a repeat group named "names".

However, following the above analogy, What I would like is the first
*name *inside
a repeat group called *names *where the attribute *eligible *= 'yes'.

The Usage column in the reference table on the webpage of the link you sent
to me shows:

indexed-repeat(field,group,index, subgroup,subidx, ssgrp,ssidx,...)

implying that the function can take more parameters than just the
field,group and index, as used in the first red-highlighted text above. But
without seeing an example of how I could use the function to pull the first
name from a group called names where the eligible attribute = yes, the
usage example shown in the second highlighted text is not helping me much
to achieve my goal so far? Not sure how clearly I have explained my
intention, but hope you can help.

Thanks in advance,
Tumaini

··· On Tue, Jan 7, 2014 at 4:02 AM, Yaw Anokwa wrote:

Yes. You can refer to items inside a repeat. See indexed-repeat at
http://opendatakit.org/help/form-design/binding/.

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Mon, Jan 6, 2014 at 12:11 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw,
Thanks, that did the trick! I do have another add-on question though...
As
mentioned earlier, I want to go into a household and

  1. Register all the household members
  2. Then for each eligible member ( 14 < age < 49 and gender = FEMALE), I
    want to ask a series of related questions.

Is it possible within the loop to display the name (or any other
attribute)
of the eligible person as captured during step 1, the registration phase?

Thanks in advance,
Tumaini

On Mon, Dec 30, 2013 at 8:15 PM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Thanks Yaw, I will have a look and modify!

Have a great new years !

On 30 Dec 2013 15:36, "Yaw Anokwa" yanokwa@nafundi.com wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read
question
grouping) which is only relevant to female members within the
household

if
they are under the age of 49. My thinking was to create a "eligible"
flag
against each household member which would be a select1 type question,
but it
should be read-only and should default to 'yes' if the person is
female

and
below the age of 49 or default to 'no' if the person is not female or
above
the age of 49. Then the number/count of these 'eligible' individuals
will be
the basis for the jr:count value which defines how many times the
group

of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the
repeat

group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)

at
org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at
org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at
org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)

at
org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)

...
...
Could anyone let me know what I could be doing wrong? Would also be
great
if I could know how this could be implemented via xlsforms. Am
attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

Does anyone know if this is possible?

Thanks

··· On Tue, Jan 7, 2014 at 10:55 AM, Tumaini Kilimba wrote:

Hello Yaw, I have had a read, but I am not sure whether it will do what I
need. Quoted below from the link you sent:

References the field of the n-th repeat of a group. Groups and indices for
1 to 3 nested repeats can be specified. For example, the XLSForm calculate
expression "indexed-repeat(${name}, ${names}, 1)" will return the value of
the first "name" field inside a repeat group named "names".

However, following the above analogy, What I would like is the first *name
*inside a repeat group called *names *where the attribute *eligible *= '
yes'.

The Usage column in the reference table on the webpage of the link you
sent to me shows:

indexed-repeat(field,group,index, subgroup,subidx, ssgrp,ssidx,...)

implying that the function can take more parameters than just the
field,group and index, as used in the first red-highlighted text above. But
without seeing an example of how I could use the function to pull the first
name from a group called names where the eligible attribute = yes, the
usage example shown in the second highlighted text is not helping me much
to achieve my goal so far? Not sure how clearly I have explained my
intention, but hope you can help.

Thanks in advance,
Tumaini

On Tue, Jan 7, 2014 at 4:02 AM, Yaw Anokwa yanokwa@nafundi.com wrote:

Yes. You can refer to items inside a repeat. See indexed-repeat at
http://opendatakit.org/help/form-design/binding/.

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Mon, Jan 6, 2014 at 12:11 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw,
Thanks, that did the trick! I do have another add-on question though...
As
mentioned earlier, I want to go into a household and

  1. Register all the household members
  2. Then for each eligible member ( 14 < age < 49 and gender = FEMALE), I
    want to ask a series of related questions.

Is it possible within the loop to display the name (or any other
attribute)
of the eligible person as captured during step 1, the registration
phase?

Thanks in advance,
Tumaini

On Mon, Dec 30, 2013 at 8:15 PM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Thanks Yaw, I will have a look and modify!

Have a great new years !

On 30 Dec 2013 15:36, "Yaw Anokwa" yanokwa@nafundi.com wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read
question
grouping) which is only relevant to female members within the
household

if
they are under the age of 49. My thinking was to create a "eligible"
flag
against each household member which would be a select1 type
question,

but it
should be read-only and should default to 'yes' if the person is
female

and
below the age of 49 or default to 'no' if the person is not female
or

above
the age of 49. Then the number/count of these 'eligible' individuals
will be
the basis for the jr:count value which defines how many times the
group

of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the
repeat

group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)

at

org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)

at

org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)

at
org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)

at
org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)

...
...
Could anyone let me know what I could be doing wrong? Would also be
great
if I could know how this could be implemented via xlsforms. Am
attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

Tumaini,

I don't think you need more than the three parameters. What if you add
relevance on that node to make it relevant only when eligible is yes.
Wouldn't that work?

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Wed, Jan 8, 2014 at 6:10 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Does anyone know if this is possible?

Thanks

On Tue, Jan 7, 2014 at 10:55 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw, I have had a read, but I am not sure whether it will do what I
need. Quoted below from the link you sent:

References the field of the n-th repeat of a group. Groups and indices for
1 to 3 nested repeats can be specified. For example, the XLSForm calculate
expression "indexed-repeat(${name}, ${names}, 1)" will return the value of
the first "name" field inside a repeat group named "names".

However, following the above analogy, What I would like is the first name
inside a repeat group called names where the attribute eligible = 'yes'.

The Usage column in the reference table on the webpage of the link you
sent to me shows:

indexed-repeat(field,group,index, subgroup,subidx, ssgrp,ssidx,...)

implying that the function can take more parameters than just the
field,group and index, as used in the first red-highlighted text above. But
without seeing an example of how I could use the function to pull the first
name from a group called names where the eligible attribute = yes, the usage
example shown in the second highlighted text is not helping me much to
achieve my goal so far? Not sure how clearly I have explained my intention,
but hope you can help.

Thanks in advance,
Tumaini

On Tue, Jan 7, 2014 at 4:02 AM, Yaw Anokwa yanokwa@nafundi.com wrote:

Yes. You can refer to items inside a repeat. See indexed-repeat at
http://opendatakit.org/help/form-design/binding/.

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Mon, Jan 6, 2014 at 12:11 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw,
Thanks, that did the trick! I do have another add-on question though...
As
mentioned earlier, I want to go into a household and

  1. Register all the household members
  2. Then for each eligible member ( 14 < age < 49 and gender = FEMALE),
    I
    want to ask a series of related questions.

Is it possible within the loop to display the name (or any other
attribute)
of the eligible person as captured during step 1, the registration
phase?

Thanks in advance,
Tumaini

On Mon, Dec 30, 2013 at 8:15 PM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Thanks Yaw, I will have a look and modify!

Have a great new years !

On 30 Dec 2013 15:36, "Yaw Anokwa" yanokwa@nafundi.com wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Dear all,
I am creating a household survey which then has a sub-survey (read
question
grouping) which is only relevant to female members within the
household
if
they are under the age of 49. My thinking was to create a
"eligible"
flag
against each household member which would be a select1 type
question,
but it
should be read-only and should default to 'yes' if the person is
female
and
below the age of 49 or default to 'no' if the person is not female
or
above
the age of 49. Then the number/count of these 'eligible'
individuals
will be
the basis for the jr:count value which defines how many times the
group
of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the
repeat
group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)
at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)
at

org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)
at

org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)
at
org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)
at
org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)
at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)
at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)
...
...
Could anyone let me know what I could be doing wrong? Would also
be
great
if I could know how this could be implemented via xlsforms. Am
attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

In an abundance of caution, we allow up to 5 repeat groups to be referenced
( 11 arguments to indexed-repeat(...) )

··· On Thu, Jan 9, 2014 at 5:32 PM, Yaw Anokwa wrote:

Tumaini,

I don't think you need more than the three parameters. What if you add
relevance on that node to make it relevant only when eligible is yes.
Wouldn't that work?

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Wed, Jan 8, 2014 at 6:10 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Does anyone know if this is possible?

Thanks

On Tue, Jan 7, 2014 at 10:55 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw, I have had a read, but I am not sure whether it will do what
I

need. Quoted below from the link you sent:

References the field of the n-th repeat of a group. Groups and indices
for

1 to 3 nested repeats can be specified. For example, the XLSForm
calculate

expression "indexed-repeat(${name}, ${names}, 1)" will return the value
of

the first "name" field inside a repeat group named "names".

However, following the above analogy, What I would like is the first
name

inside a repeat group called names where the attribute eligible = 'yes'.

The Usage column in the reference table on the webpage of the link you
sent to me shows:

indexed-repeat(field,group,index, subgroup,subidx, ssgrp,ssidx,...)

implying that the function can take more parameters than just the
field,group and index, as used in the first red-highlighted text above.
But

without seeing an example of how I could use the function to pull the
first

name from a group called names where the eligible attribute = yes, the
usage

example shown in the second highlighted text is not helping me much to
achieve my goal so far? Not sure how clearly I have explained my
intention,

but hope you can help.

Thanks in advance,
Tumaini

On Tue, Jan 7, 2014 at 4:02 AM, Yaw Anokwa yanokwa@nafundi.com wrote:

Yes. You can refer to items inside a repeat. See indexed-repeat at
http://opendatakit.org/help/form-design/binding/.

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Mon, Jan 6, 2014 at 12:11 AM, Tumaini Kilimba tkilimba@ihi.or.tz wrote:

Hello Yaw,
Thanks, that did the trick! I do have another add-on question
though...

As
mentioned earlier, I want to go into a household and

  1. Register all the household members
  2. Then for each eligible member ( 14 < age < 49 and gender =
    FEMALE),

I
want to ask a series of related questions.

Is it possible within the loop to display the name (or any other
attribute)
of the eligible person as captured during step 1, the registration
phase?

Thanks in advance,
Tumaini

On Mon, Dec 30, 2013 at 8:15 PM, Tumaini Kilimba <tkilimba@ihi.or.tz wrote:

Thanks Yaw, I will have a look and modify!

Have a great new years !

On 30 Dec 2013 15:36, "Yaw Anokwa" yanokwa@nafundi.com wrote:

It's not compiling because you are missing an open parenthesis.

You wrote:
<bind calculate="if(/xls_f

It should be:
<bind calculate="if((/xls_f

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Sun, Dec 29, 2013 at 7:30 AM, Tumaini Kilimba < tkilimba@ihi.or.tz> wrote:

Dear all,
I am creating a household survey which then has a sub-survey
(read

question
grouping) which is only relevant to female members within the
household
if
they are under the age of 49. My thinking was to create a
"eligible"
flag
against each household member which would be a select1 type
question,
but it
should be read-only and should default to 'yes' if the person is
female
and
below the age of 49 or default to 'no' if the person is not
female

or
above
the age of 49. Then the number/count of these 'eligible'
individuals
will be
the basis for the jr:count value which defines how many times the
group
of
questions that are meant for women under the age of 49 within the
household
should be repeated (i.e if there are 2 eligible women, then the
repeat
group
for questions for eligible women should loop twice).

I have attempted to do it with this binding below:

  <bind calculate="if(/xls_form_test/members/age &lt; 49 and

/xls_form_test/members/gender='f'),'yes','no')"
nodeset="/xls_form_test/members/eligible" type="select1"/>

but on putting this through Validate, I get the error:

Invalid XPath expression [if(/xls_form_test/members/age < 49 and
/xls_form_test/members/gender='f'),'yes','no')]!
java.lang.NullPointerException
java.lang.NullPointerException
at
org.javarosa.core.model.FormDef.addTriggerable(FormDef.java:526)

at

org.javarosa.xform.parse.XFormParser.processStandardBindAttributes(XFormParser.java:1501)

at

org.javarosa.xform.parse.XFormParser.parseBind(XFormParser.java:1521)

at

org.javarosa.xform.parse.XFormParser.parseModel(XFormParser.java:460)

at

org.javarosa.xform.parse.XFormParser.access$200(XFormParser.java:78)

at

org.javarosa.xform.parse.XFormParser$3.handle(XFormParser.java:153)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:375)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)

at

org.javarosa.xform.parse.XFormParser.parseElement(XFormParser.java:386)

...
...
Could anyone let me know what I could be doing wrong? Would also
be
great
if I could know how this could be implemented via xlsforms. Am
attaching the
whole xml file as reference.

Thanks in advance,
Tumaini

--

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/groups/opt_out
.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--

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/groups/opt_out.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com