I'm working on some tests for JavaRosa and I'm trying to build a form that will verify relations between inner and outer groups in an abstract way. The forms have no real use in the field.
Let's say I have a form with a repeat group and a field inside the group that keeps the count of the number of repeats there are as in:
@ggalmazor and I did some pairing on this and it turned out that he was working off some code with a regression in it. This test works great in released versions of JavaRosa/Collect!
It's basically the same form from my original post but now there are a couple of nested repeat groups. If I create 3 inner groups in the first outer group, and 2 inner groups in the second outer group, I'd expect the following instance:
An absolute ref as in calculate="count(/data/outer/inner)" works, but it gives me the count of all inner groups regardless to what outer group they belong to (5 in all counts).
It looks like the parent ref in the calculate="count(..)" of /data/outer/inner/count isn't resolving the ref we need aka /data/outer[x]/inner (xthouter instance, unbound inner instance).
Instead, it's resolving the specific ythinner instance where the field's at, which is kinda reasonable too, since the parent ref shouldn't change anything about the parent of the field itself, and the field is actually at position outer[x]/inner[y].
I'm also trying with calculate="count(../../inner)", which reads as "go up to the ythinner instance, go up to the xthouter instance, then down to an unbounded inner ref", but it's still giving me 1 as count results.
Following the triggerable evaluation code, it all goes down to how we're contextualizing the triggerable's target refs with the evaluation context's ref. These assertions explain the core of the problem: