Relevance condition in current repeat doesn't work (based on earlier repeat group answers)

Hi All,

This question is extension to
https://groups.google.com/forum/#!searchin/opendatakit/repeat$20group/opendatakit/Dxp9BH1WuBg/_ujYdCFZG0gJ

Following relevant conditions seems not to work in current repeat group
question, question (/data/PeopleQuestion/perQues) always get skipped even
when age in earlier repeat group for the member is greater than 10:

/data/People[position(current()/.)]/Age > 10

and:

/data/People[position(..)]/Age > 10

and:

/data/People[/data/PeopleQuestion/repeatCount]/Age > 10

I guess i must be doing something simple yet very wrong. Any ideas are
greatly appreciated.

Best Regards,
Ayub

dynamic_list.xml (6.13 KB)

In this case, I think you want

/data/People[position(current()/..)]/Age > 10

Remember that whenever you use .. within a filter condition of an XPath, it
refers to the parent of the XPath node under consideration. So in
/data/People[position(..)], the .. refers to /data because it is evaluated
relative to the /data/People XPath expression.

To reference the current question's location, you need to refer to
current()/. And in this case, you want the group containing that question
to access the corresponding group in the earlier question, so you want

position(current()/..) -- using the .. to reference the group containing
the current question.

( Note that in the earlier question, the answer revealed a software bug
that required using current()/. instead of current()/.. for the evaluation
of the itemset. The correct answer should have been current()/.. , as it is
in this case )

Mitch

··· On Mon, Oct 6, 2014 at 7:46 AM, Ayub wrote:

Hi All,

This question is extension to
https://groups.google.com/forum/#!searchin/opendatakit/repeat$20group/opendatakit/Dxp9BH1WuBg/_ujYdCFZG0gJ

Following relevant conditions seems not to work in current repeat group
question, question (/data/PeopleQuestion/perQues) always get skipped even
when age in earlier repeat group for the member is greater than 10:

/data/People[position(current()/.)]/Age > 10

and:

/data/People[position(..)]/Age > 10

and:

/data/People[/data/PeopleQuestion/repeatCount]/Age > 10

I guess i must be doing something simple yet very wrong. Any ideas are
greatly appreciated.

Best Regards,
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

Hi Mitch,

Unfortunately this also doesn't work: (question never shows up for greater
than 10 age members)

/data/People[position(current()/..)]/Age > 10

I am also outputting value of current age of the member in a read-only
prompt like so:

And this one is always empty.

Thanks for the detailed answer and quick reply. Now i have checked with
both single (.) and (..) two dots and none of them work :frowning: . I am also
trying my best to find what's preventing this to work properly.

Best,
Ayub

Hi Mitch,

So far it seems as if Age from earlier repeat is never returned in either
a) Relevant and b) *Calculate *part of the question, so the expression
(always) becomes:

'' > 10

This looked really simple and the general idea was that it should work.
After spending few days, i think i am out of ideas. I would highly
appreciate ideas/workarounds on this.

Best Regards,
Ayub

Finally getting back to this --

I forgot that the (otherwise-valid) XPath expression:

/blah/blah[5]/foo

doesn't work in the Javarosa codebase. That is effectively what:

/blah/blah[position(current()/..)]/foo

evaluates to.

The work-around is to use an equality predicate:

/blah/blah[position(.)=position(current()/..)]/foo

I.e., in this case:

      <label>REPEAT = <output value="/data/PeopleQuestion/repeatCount"/>
            AGE FOR THIS MEMBER = <output

value="/data/People[position(.) = position(current()/..)]/Age"/>

and, earlier:

 <bind nodeset="/data/PeopleQuestion/perQues" type="integer"

required="true()"
relevant="/data/People[position(.)=position(current()/..)]/Age > 10"/>

See attached survey

new_dynamic_list.xml (6.36 KB)

··· On Wed, Oct 8, 2014 at 8:38 AM, Ayub wrote:

Hi Mitch,

So far it seems as if Age from earlier repeat is never returned in either
a) Relevant and b) *Calculate *part of the question, so the expression
(always) becomes:

'' > 10

This looked really simple and the general idea was that it should work.
After spending few days, i think i am out of ideas. I would highly
appreciate ideas/workarounds on this.

Best Regards,
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, this works just as required.

I have some follow up questions on that, i saw some people quoting
solutions on these forums i.e.

/blah/blah[5]/foo

to similar problems, this however doesn't work in ODK as ODK is based on
Javarosa. Does this mean they are using custom version of Javarosa or some
other library?

Thanks once again, i really appreciate your help on this!

Best,
Ayub

Enketo, I believe, is using a different XPath expression parser (it is all
in javascript), so it likely does not have all of the quirks that Javarosa
does.

But, in general, I have no idea. I am not aware of ODK variants that do not
use Javarosa.

··· On Sat, Nov 15, 2014 at 3:11 AM, Ayub wrote:

Thanks Mitch, this works just as required.

I have some follow up questions on that, i saw some people quoting
solutions on these forums i.e.

/blah/blah[5]/foo

to similar problems, this however doesn't work in ODK as ODK is based on
Javarosa. Does this mean they are using custom version of Javarosa or some
other library?

Thanks once again, i really appreciate your help on this!

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

Mitch,

Lets say I want to check if some selection was made earlier in a repeat
group by checking all (previous) positions for a question, what would the
constraint look like (I have tried the following)

This doesn't work:

constraint=". != /data/hhMembers[hhNameSel]"

This works but only checks the last position or a position before (as
expected):

(. != /data/hhMembers[position(.)=position(current()/..)-1]/hhNameSel)

In short, is there a dynamic way to test for a value against all positions
of a repeat group question?

Best,
Ayub