Note that static selection s that are inline in the XML are
maintained in a different data structure than are the dynamic s
that reference named instance('...')... sections.
e.g.,
What is your gender?
<label ref="jr:itext('/NBiggestOfSet/select_example/male:label')/>
male
ref="jr:itext('/NBiggestOfSet/select_example/female:label'
female
vs.
Are handled and parsed differently.
There are several different things to test:
(1) the filter condition ( <itemset nodeset="..." ) on the dynamic
itemsets has the correct current()/. path. (known issue).
(2a) within an , the has the correct
current()/. path. I believe these are abitrary xpath expressions relative
to the nodeset path. We just happen to use a simple leaf node expression
and we hack the jr:itext() using special parsing. We should be able to
hand-code something crazy like
ref="value/../alt[./name=current()/../otherChoice]/value"
(2b) within an the only allowed label ref= is for a jr:itext()
path. That value may contain an tag, so the evaluation concern
still applies, but only w.r.t. (4) below. I.e., nothing to test here;
handled in testing (4).
(3a) within an , the has the correct
current()/. path. I believe these are abitrary xpath expressions relative
to the nodeset path. We just happen to use a simple leaf node expression.
See (2a) for example of craziness.
(3b) within an the entry does not take a ref="..."
attribute and must be a string value. I.e., nothing to test here.
(4) tags within a (either within an or
an entry, and either within a jr:itext or inlined) have the
correct current()/. path. I believe these are abitrary xpath expressions
relative to the nodeset path. We just happen to use a simple node reference.
(5) jr:choice-name() evaluates the filter condition, (1), above, correctly
for dynamic itemsets. This might have a bug with resolving tags
-- not sure I've ever seen a form using them and using this function.
The function that does the parsing is XFormParser.parseItemset
https://bitbucket.org/m.sundt/javarosa/src/bf17fb749b74e53915f086ca3827c3c6fe73fd07/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-1206
This may use the incorrect contextRef (e.g., line 1226) ? And maybe that
is the root of the problem?
The function that does the parsing is XFormParser.parseItem
https://bitbucket.org/m.sundt/javarosa/src/bf17fb749b74e53915f086ca3827c3c6fe73fd07/core/src/org/javarosa/xform/parse/XFormParser.java?at=default&fileviewer=file-view-default#XFormParser.java-1118
The function that does the evaluation is
FormDef.populateDynamicChoices
https://bitbucket.org/m.sundt/javarosa/src/bf17fb749b74e53915f086ca3827c3c6fe73fd07/core/src/org/javarosa/core/model/FormDef.java?at=default&fileviewer=file-view-default#FormDef.java-919
On Sun, Nov 15, 2015 at 6:13 PM, Yaw Anokwa yanokwa@nafundi.com wrote:
Chris,
It's been forever since I looked at the itemset code, so I'm not going
to be very useful here.
Yaw
Need ODK consultants? Nafundi provides form design, server setup,
in-field training, and software development for ODK. Go to
https://nafundi.com to get started.
On Mon, Nov 16, 2015 at 2:13 AM, Christopher Robert crobert@surveycto.com wrote:
Okay, since everybody seems bullish about changing the JavaRosa behavior
here, does anybody have ideas on how to do it safely? Making a change
like
this seems at high risk for not only breaking forms that rely on
behavior
judged improper ex post, but even forms that rely on correct behavior.
And
since nobody seems 100% clear on what precisely correct behavior should
be
in every circumstance, the risks of messing up seem even higher than is
usual for any JavaRosa intervention.
I'd like to empower users to refer to repeated values using XLSForm
choice
filters, and this now seems fully within reach (in fact I have it
working
nicely here already). But if that's going to require a major and risky
JavaRosa adventure, then I am far less sure that the benefits outweigh
the
costs.
Yaw, do you understand that itemset/predicate evaluation code? Or Mitch,
since it sounds like you added this current current() support, can you
suggest where it might have gone wrong?
Thanks all,
Chris
On Sun, Nov 15, 2015 at 1:57 AM Yaw Anokwa yanokwa@nafundi.com wrote:
Chris,
I think correct behavior is more important than keeping compatibility.
You can only carry technical debt for so long...
We can warn at on the first the form is loaded in release 0, that
folks should fix their forms. Then in release 1, warn every time the
form is loaded. Then release 2, we change the behavior.
Yaw
Need ODK consultants? Nafundi provides form design, server setup,
in-field training, and software development for ODK. Go to
https://nafundi.com to get started.
On Sat, Nov 14, 2015 at 10:36 AM, Christopher Robert crobert@surveycto.com wrote:
Since there are literally thousands of devices in the field running
current
and older versions of Collect -- and will be for a very long time
yet --
we
cannot implement a change that will create forms incompatible with
all
of
those devices. In other words, if Collect/JR is "fixed" such that
current()
in itemset predicates point to the field rather than one step back
from
the
field, then we can neither introduce a pyxform that relies on the
fixed
version nor introduce a pyxform that relies on the broken version.
Too
many
devices would experience problems in both directions.
So, it seems our choices are: (1) fix the SurveyCTO pyxform to rely
on
the
current "broken" JR , maintain that flaw in SurveyCTO's JR branch,
and
live
with SurveyCTO's cascading selects breaking compatibility with
Enketo;
or
(2) leave things as they are so users are unable to refer to
within-context
repeated values in cascading-select filters. An in-between option
would
be
to document the current() approach for people to hand-code the proper
XPaths
into their XLSForms -- but even that is problematic if JR's
treatment of
current() is going to change (and/or if Enketo's current() is going
to
behave differently).
For what it's worth, "fixed" versions of Collect that change the
nature
of
current() in itemset predicates will break all forms for all users
who
have
taken the advice to use current() in their cascading-select filters.
It
will
be a pretty painful break, I imagine.
If anybody has an idea about how to resolve all of this without
breaking
compatibility for thousands of devices and forms, I'm all ears.
Thanks!
Chris
On Fri, Nov 13, 2015 at 6:03 PM Martijn van de Rijdt martijn@enketo.org wrote:
Thanks Mitch,
Indeed relative paths with current() are very useful. Pyxform
${syntax}
translation for choice-lists (as a start
to use relative paths
with
current() is very welcome indeed Chris!
I hadn't realized current() was part of XForms (just found XSLT
references), but I see this now in XForms 2.0:
http://www.w3.org/TR/xforms-xpath/#The_current.28.29_Function, so
indeed it
is a bug.
I'll implement current() to be the current field then (in Enketo).
On Fri, Nov 13, 2015 at 3:18 PM, Mitch Sundt < mitchellsundt@gmail.com> wrote:
I think this is a bug.
But I don't know what the XForms standard says about this
(frankly, my
eyes glaze over on the spec document, so I have played fast and
loose
with
compliance).
As a counter-example, attached is a form that uses current()
inside a
calculation and an tag. In both those circumstances,
current()/. is
the field and not the group containing the field.
So I think that the choice list reference is incorrect.
I think current()/. should point to the field, and not the
group
containing the field when we try to resolve the choice list.
For the attached XLS file, if you work from the xls file, you need
to
hand-edit the xml to change the tag to be what it needs to
be.
Changing ${fieldname} to expand using current()/... syntax would
be an
awesome contribution.
Not sure what impact it has on indexed-repeat().
Assuming it is a bug, we should change javarosa to have this
reference
the field and not the enclosing group.
Not sure how to manage or coordinate deploying this bug fix.
COMPATIBILITY NOTE:
The ODK fork of javarosa ( https://bitbucket.org/m.sundt/javarosa
)
has
enhanced syntax on current()/ w.r.t. the Dimagi / CommCare base
repo (
https://bitbucket.org/javarosa/ ), at least as of the time I
forked
from
that repo. When this was forked, I added support for relative path
expressions -- in the javarosa Dimagi branch, current()/ did not
support
relative path expressions (e.g., current()/../...). It only
supported
absolute path expressions (i.e.,
current()/myform/group1/fieldname).
I don't know whether that change conforms to the XForms spec or if
it
is
divergent (but it is extremely useful and powerful).
On Fri, Nov 13, 2015 at 1:46 PM, Christopher Robert crobert@surveycto.com wrote:
Thanks, Martijn, for posting this.
For a bit of context, this came up because we've patched
SurveyCTO's
pyxform branch to replace ${x} references in choice_filter columns
with
expressions relative to current() so that users can refer to
repeated
values
(from within the current repeat context) in cascading selects. Our
solution
seems to work with the current version of JR/Collect, but it
relies
on this
behavior that Martijn discusses.
If the behavior is judged stable and desirable, then we're happy
to
move
forward with a patched pyxform and also share that with the
community. Users
will celebrate if the restriction on easily referencing in-context
repeat
fields were lifted.
Thanks,
Chris
On Fri, Nov 13, 2015 at 4:38 PM Martijn van de Rijdt martijn@enketo.org wrote:
Hi,
I'd like to ask for a clarification about the current() node in
an
XPath predicate. It seems JR considers this to be the parent
node of
the
current question. (Thanks to Chris for sharing this.)
E.g. in this question below, current() equates to /data/group and
not
to /data/group/options. I would have expected it to be the
latter.
....
<label>label</label>
<itemset nodeset="instance('crop_list')/root/item[name =
current()/../crop]">
....
....
</itemset>
Is this by design? Or is it a bug?
We ran into this by realizing that the seemingly more intuitive
predicate [name = current()/../../crop] is not working.
See this form that illustrates the behaviour nicely. If
current() is
used in a calculation (even if it makes no sense to do so) this
extra step
down is not taken, but in a predicate it is. So it seems the
behaviour is
not related to the current() function but to how predicates are
handled in
JR.
Thanks,
Martijn
--
Revolutionizing data collection since 2012.
Enketo | LinkedIn | GitHub | Twitter |
Blog
--
You received this message because you are subscribed to the
Google
Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it,
send
an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it,
send
an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com
--
You received this message because you are subscribed to a topic in
the
Google Groups "ODK Developers" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit-developers/nN8HTA5pUIM/unsubscribe
.
To unsubscribe from this group and all its topics, send an email to
opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Revolutionizing data collection since 2012.
Enketo | LinkedIn | GitHub | Twitter | Blog
--
You received this message because you are subscribed to the Google
Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it,
send
an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it,
send
an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com
--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.