Result of a calcuation in a hint, using absolute path?

I am creating notes which display how list choices are being filtered. One
of the filters is set by a calculation and since my my form has a number of
repeats within repeats, I need to use absolute paths rather than just
referring to the field name. If I sent the hint of the note to something
like this:

Filtering List Choices For: ../../g28/filter_calc_1 Photos

The path text, not the actual calculation result displays. How can I get
the actual result to display?

This likely requires editing the XML file, as I doubt anything is available
in XLSForm for this.

Basically, when you have a label like

Enter age of ${member_name}

It gets expanded in the XML file as:

Enter age of

··· ======================= What you'd like to write in your label is:

Filtering List Choices For: ${../../g28/filter_calc_1} Photos

But I doubt XLSForm will detect and accept that.

And I am pretty sure it would change:

Filtering List Choices For: Photos

so that the embedded XML <output... /> was escaped as <output... />

On Sun, Mar 20, 2016 at 1:29 PM, Adrian Martinez adrianthorn101@gmail.com wrote:

I am creating notes which display how list choices are being filtered.
One of the filters is set by a calculation and since my my form has a
number of repeats within repeats, I need to use absolute paths rather than
just referring to the field name. If I sent the hint of the note to
something like this:

Filtering List Choices For: ../../g28/filter_calc_1 Photos

The path text, not the actual calculation result displays. How can I get
the actual result to display?

--

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

Well that is a pain. I altered the XML so the filter appears correctly but
now I am stalling with the calculation, which includes a jr:choice-name. If
I go through the form, it works as intended. If I close the form then
reopen it, I get the following error message:

"Error evaluating field 'filter_2_calc': error in evaluation of xpath
function [choice-name] =>
org.javarosa.xpath.XPathTypeMismatchException[Xpath evaluation: type
mismatch This field is repeated:

instance(experimental)/Tester/r1[1]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[2]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[3]/g26[1]/type_calc[1]"

Now this isn't terribly surprising, since I didn't use an absolute path for
filter_2_calc:

if(../../g25/external = '', 'unspecified',
jr:choice-name(${photo_type},'${photo_type}'))

But when I do use an absolute path with jr:choice-name like so:

if(../../g25/external = '', 'unspecified',
jr:choice-name(../../g27/photo_type},'../../g27/photo_type}'))

jr:choice-name returns nothing. I suspect I already know the problem,
since photo_type uses a choice_filter and the ODK bindings page says
jr:choice-name doesn't work with filters. If the filter is the problem,
whats a work around? Can I duplicate the list, add in intermediary
calculation that results in name chosen from the filtered list, then have
filter_2_calc check the duplicate list against the result intermediary
calculation?

If the choice filter isn't the problem, whats wrong with the calculation?
I've attached a gutted version of my form and the xml if you want to take a
peek.

Tester.xml (36.8 KB)

Tester.xlsx (23.6 KB)

··· On Wednesday, March 23, 2016 at 12:21:40 PM UTC-6, Mitch Sundt wrote: > > This likely requires editing the XML file, as I doubt anything is > available in XLSForm for this. > > Basically, when you have a label like > > Enter age of ${member_name} > > It gets expanded in the XML file as: > > Enter age of > > ======================= > What you'd like to write in your label is: > > Filtering List Choices For: ${../../g28/filter_calc_1} Photos > > But I doubt XLSForm will detect and accept that. > > And I am pretty sure it would change: > > Filtering List Choices For: > Photos > > so that the embedded XML was escaped as <output... /> > > > > > On Sun, Mar 20, 2016 at 1:29 PM, Adrian Martinez <adriant...@gmail.com > wrote: > >> I am creating notes which display how list choices are being filtered. >> One of the filters is set by a calculation and since my my form has a >> number of repeats within repeats, I need to use absolute paths rather than >> just referring to the field name. If I sent the hint of the note to >> something like this: >> >> Filtering List Choices For: ../../g28/filter_calc_1 Photos >> >> The path text, not the actual calculation result displays. How can I get >> the actual result to display? >> >> -- >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@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...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com >

This is probably fixed by a patch to JR that was just submitted by Survey
CTO (
https://bitbucket.org/m.sundt/javarosa/commits/7c74ff5eb7cb046ce1d279f72dfc7cfe384b9fd3
).

That patch will be in the next ODK Collect release; I haven't yet built and
propagated the javarosa patch, so it is not yet checked into all the ODK
tools that will need it (so you can't yet build ODK Collect from source to
get it).

Once I complete an ODK Aggregate development environment update, I will
propagate the patch in preparation for an ODK 1.x release (led by ODK
Aggregate).

No ETA, as the development environment update is being particularly irksome.

··· On Thu, Mar 24, 2016 at 11:17 AM, Adrian Martinez wrote:

Well that is a pain. I altered the XML so the filter appears correctly
but now I am stalling with the calculation, which includes a
jr:choice-name. If I go through the form, it works as intended. If I close
the form then reopen it, I get the following error message:

"Error evaluating field 'filter_2_calc': error in evaluation of xpath
function [choice-name] =>
org.javarosa.xpath.XPathTypeMismatchException[Xpath evaluation: type
mismatch This field is repeated:

instance(experimental)/Tester/r1[1]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[2]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[3]/g26[1]/type_calc[1]"

Now this isn't terribly surprising, since I didn't use an absolute path
for filter_2_calc:

if(../../g25/external = '', 'unspecified',
jr:choice-name(${photo_type},'${photo_type}'))

But when I do use an absolute path with jr:choice-name like so:

if(../../g25/external = '', 'unspecified',
jr:choice-name(../../g27/photo_type},'../../g27/photo_type}'))

jr:choice-name returns nothing. I suspect I already know the problem,
since photo_type uses a choice_filter and the ODK bindings page says
jr:choice-name doesn't work with filters. If the filter is the problem,
whats a work around? Can I duplicate the list, add in intermediary
calculation that results in name chosen from the filtered list, then have
filter_2_calc check the duplicate list against the result intermediary
calculation?

If the choice filter isn't the problem, whats wrong with the calculation?
I've attached a gutted version of my form and the xml if you want to take a
peek.

On Wednesday, March 23, 2016 at 12:21:40 PM UTC-6, Mitch Sundt wrote:

This likely requires editing the XML file, as I doubt anything is
available in XLSForm for this.

Basically, when you have a label like

Enter age of ${member_name}

It gets expanded in the XML file as:

Enter age of

=======================
What you'd like to write in your label is:

Filtering List Choices For: ${../../g28/filter_calc_1} Photos

But I doubt XLSForm will detect and accept that.

And I am pretty sure it would change:

Filtering List Choices For:
Photos

so that the embedded XML <output... /> was escaped as <output... />

On Sun, Mar 20, 2016 at 1:29 PM, Adrian Martinez adriant...@gmail.com wrote:

I am creating notes which display how list choices are being filtered.
One of the filters is set by a calculation and since my my form has a
number of repeats within repeats, I need to use absolute paths rather than
just referring to the field name. If I sent the hint of the note to
something like this:

Filtering List Choices For: ../../g28/filter_calc_1 Photos

The path text, not the actual calculation result displays. How can I get
the actual result to display?

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

--

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

Well its good to hear that some kind of solution for dynamic lists is
forthcoming! What about using absolute paths and jr:choice-name with
non-dynamic lists? I can't get it to recognize any absolute path.

··· On Thursday, March 24, 2016 at 1:43:40 PM UTC-6, Mitch Sundt wrote: > > This is probably fixed by a patch to JR that was just submitted by Survey > CTO ( > https://bitbucket.org/m.sundt/javarosa/commits/7c74ff5eb7cb046ce1d279f72dfc7cfe384b9fd3 > ). > > That patch will be in the next ODK Collect release; I haven't yet built > and propagated the javarosa patch, so it is not yet checked into all the > ODK tools that will need it (so you can't yet build ODK Collect from source > to get it). > > Once I complete an ODK Aggregate development environment update, I will > propagate the patch in preparation for an ODK 1.x release (led by ODK > Aggregate). > > No ETA, as the development environment update is being particularly > irksome. > > > On Thu, Mar 24, 2016 at 11:17 AM, Adrian Martinez <adriant...@gmail.com > wrote: > >> Well that is a pain. I altered the XML so the filter appears correctly >> but now I am stalling with the calculation, which includes a >> jr:choice-name. If I go through the form, it works as intended. If I close >> the form then reopen it, I get the following error message: >> >> "Error evaluating field 'filter_2_calc': error in evaluation of xpath >> function [choice-name] => >> org.javarosa.xpath.XPathTypeMismatchException[Xpath evaluation: type >> mismatch This field is repeated: >> >> >> instance(experimental)/Tester/r1[1]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[2]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[3]/g26[1]/type_calc[1]" >> >> Now this isn't terribly surprising, since I didn't use an absolute path >> for filter_2_calc: >> >> if(../../g25/external = '', 'unspecified', >> jr:choice-name(${photo_type},'${photo_type}')) >> >> But when I do use an absolute path with jr:choice-name like so: >> >> if(../../g25/external = '', 'unspecified', >> jr:choice-name(../../g27/photo_type},'../../g27/photo_type}')) >> >> jr:choice-name returns nothing. I suspect I already know the problem, >> since photo_type uses a choice_filter and the ODK bindings page says >> jr:choice-name doesn't work with filters. If the filter is the problem, >> whats a work around? Can I duplicate the list, add in intermediary >> calculation that results in name chosen from the filtered list, then have >> filter_2_calc check the duplicate list against the result intermediary >> calculation? >> >> If the choice filter isn't the problem, whats wrong with the >> calculation? I've attached a gutted version of my form and the xml if you >> want to take a peek. >> >> On Wednesday, March 23, 2016 at 12:21:40 PM UTC-6, Mitch Sundt wrote: >>> >>> This likely requires editing the XML file, as I doubt anything is >>> available in XLSForm for this. >>> >>> Basically, when you have a label like >>> >>> Enter age of ${member_name} >>> >>> It gets expanded in the XML file as: >>> >>> Enter age of >>> >>> ======================= >>> What you'd like to write in your label is: >>> >>> Filtering List Choices For: ${../../g28/filter_calc_1} Photos >>> >>> But I doubt XLSForm will detect and accept that. >>> >>> And I am pretty sure it would change: >>> >>> Filtering List Choices For: >>> Photos >>> >>> so that the embedded XML was escaped as <output... /> >>> >>> >>> >>> >>> On Sun, Mar 20, 2016 at 1:29 PM, Adrian Martinez wrote: >>> >>>> I am creating notes which display how list choices are being filtered. >>>> One of the filters is set by a calculation and since my my form has a >>>> number of repeats within repeats, I need to use absolute paths rather than >>>> just referring to the field name. If I sent the hint of the note to >>>> something like this: >>>> >>>> Filtering List Choices For: ../../g28/filter_calc_1 Photos >>>> >>>> The path text, not the actual calculation result displays. How can I >>>> get the actual result to display? >>>> >>>> -- >>>> -- >>>> Post: opend...@googlegroups.com >>>> Unsubscribe: opendatakit...@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...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Mitch Sundt >>> Software Engineer >>> University of Washington >>> mitche...@gmail.com >>> >> -- >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@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...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com >

Nevermind, I found a solution to both using absolute paths in
jr:choice-name (you don't need to) and a simple workaround to not being
able to use dynamic-lists with it.

In case others need a work around before the next version of ODK comes out,
all you need to do is:

  1. Duplicate the choice list used by the filtered question, removing all
    filters for the duplicate list.
  2. Create a new question with a relevant condition that cannot be
    satisfied. (So you don't see the new question).
  3. Set the choice list for the new question to the duplicated list.

Set the "value" part of jr:choice-list to the path to the filter question,
the "xpath/to/node" part to the path to the new question.

jr:choice-name(value, 'xpath/to/node')

I have attached an example xls in case someone needs to see it. In the case
of my example, the workaround looks like:

jr:choice-name(/Tester/r1/g2/filtered_question,
'/Tester/r1/g2/new_question')

Tester.xlsx (13.1 KB)

··· On Thursday, March 24, 2016 at 2:43:53 PM UTC-6, Adrian Martinez wrote: > > Well its good to hear that some kind of solution for dynamic lists is > forthcoming! What about using absolute paths and jr:choice-name with > non-dynamic lists? I can't get it to recognize any absolute path. > > On Thursday, March 24, 2016 at 1:43:40 PM UTC-6, Mitch Sundt wrote: >> >> This is probably fixed by a patch to JR that was just submitted by Survey >> CTO ( >> https://bitbucket.org/m.sundt/javarosa/commits/7c74ff5eb7cb046ce1d279f72dfc7cfe384b9fd3 >> ). >> >> That patch will be in the next ODK Collect release; I haven't yet built >> and propagated the javarosa patch, so it is not yet checked into all the >> ODK tools that will need it (so you can't yet build ODK Collect from source >> to get it). >> >> Once I complete an ODK Aggregate development environment update, I will >> propagate the patch in preparation for an ODK 1.x release (led by ODK >> Aggregate). >> >> No ETA, as the development environment update is being particularly >> irksome. >> >> >> On Thu, Mar 24, 2016 at 11:17 AM, Adrian Martinez wrote: >> >>> Well that is a pain. I altered the XML so the filter appears correctly >>> but now I am stalling with the calculation, which includes a >>> jr:choice-name. If I go through the form, it works as intended. If I close >>> the form then reopen it, I get the following error message: >>> >>> "Error evaluating field 'filter_2_calc': error in evaluation of xpath >>> function [choice-name] => >>> org.javarosa.xpath.XPathTypeMismatchException[Xpath evaluation: type >>> mismatch This field is repeated: >>> >>> >>> instance(experimental)/Tester/r1[1]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[2]/g26[1]/type_calc[1];instance(experimental)/Tester/r1[3]/g26[1]/type_calc[1]" >>> >>> Now this isn't terribly surprising, since I didn't use an absolute path >>> for filter_2_calc: >>> >>> if(../../g25/external = '', 'unspecified', >>> jr:choice-name(${photo_type},'${photo_type}')) >>> >>> But when I do use an absolute path with jr:choice-name like so: >>> >>> if(../../g25/external = '', 'unspecified', >>> jr:choice-name(../../g27/photo_type},'../../g27/photo_type}')) >>> >>> jr:choice-name returns nothing. I suspect I already know the problem, >>> since photo_type uses a choice_filter and the ODK bindings page says >>> jr:choice-name doesn't work with filters. If the filter is the problem, >>> whats a work around? Can I duplicate the list, add in intermediary >>> calculation that results in name chosen from the filtered list, then have >>> filter_2_calc check the duplicate list against the result intermediary >>> calculation? >>> >>> If the choice filter isn't the problem, whats wrong with the >>> calculation? I've attached a gutted version of my form and the xml if you >>> want to take a peek. >>> >>> On Wednesday, March 23, 2016 at 12:21:40 PM UTC-6, Mitch Sundt wrote: >>>> >>>> This likely requires editing the XML file, as I doubt anything is >>>> available in XLSForm for this. >>>> >>>> Basically, when you have a label like >>>> >>>> Enter age of ${member_name} >>>> >>>> It gets expanded in the XML file as: >>>> >>>> Enter age of >>>> >>>> ======================= >>>> What you'd like to write in your label is: >>>> >>>> Filtering List Choices For: ${../../g28/filter_calc_1} Photos >>>> >>>> But I doubt XLSForm will detect and accept that. >>>> >>>> And I am pretty sure it would change: >>>> >>>> Filtering List Choices For: >>>> Photos >>>> >>>> so that the embedded XML was escaped as <output... >>>> /> >>>> >>>> >>>> >>>> >>>> On Sun, Mar 20, 2016 at 1:29 PM, Adrian Martinez wrote: >>>> >>>>> I am creating notes which display how list choices are being >>>>> filtered. One of the filters is set by a calculation and since my my form >>>>> has a number of repeats within repeats, I need to use absolute paths rather >>>>> than just referring to the field name. If I sent the hint of the note to >>>>> something like this: >>>>> >>>>> Filtering List Choices For: ../../g28/filter_calc_1 Photos >>>>> >>>>> The path text, not the actual calculation result displays. How can I >>>>> get the actual result to display? >>>>> >>>>> -- >>>>> -- >>>>> Post: opend...@googlegroups.com >>>>> Unsubscribe: opendatakit...@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...@googlegroups.com. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> Mitch Sundt >>>> Software Engineer >>>> University of Washington >>>> mitche...@gmail.com >>>> >>> -- >>> -- >>> Post: opend...@googlegroups.com >>> Unsubscribe: opendatakit...@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...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Mitch Sundt >> Software Engineer >> University of Washington >> mitche...@gmail.com >> >