Cascading select in repeat loop

Hi,

I am running in to a problem and I hope you will help me. I am using cascading selects in a repeat loop, and I have an XPATH exception "XPath evaluation: type mismatch This field is repeated... You may need to use the indexed-repeat() function to specify which value you want...", when I am entering the second record

I googled and I found that the problem was unresolved in 2013:
https://groups.google.com/forum/#!topic/opendatakit/SPuPrrOdAno

Thanks,

The newest ODK Collect 1.4.3 may help (it is up on the site but not pushed
to Google Play or announced, pending an update to XLSForm to support
search-and-select functionality).

In that release, there is now a current() qualifier to an XPath expression,
so within a repeat group, you can do something like

instance('cities')/ref/country[name=current()/../coutry_name]/district[name=current()/../district_name]/city/name

I.e., use the current()/.. to reference a field in the repeat group of the
form you are filling out. This was previously not possible.

Mitch

··· On Thu, May 8, 2014 at 4:25 AM, wrote:

Hi,

I am running in to a problem and I hope you will help me. I am using
cascading selects in a repeat loop, and I have an XPATH exception "XPath
evaluation: type mismatch This field is repeated... You may need to use the
indexed-repeat() function to specify which value you want...", when I am
entering the second record

I googled and I found that the problem was unresolved in 2013:
https://groups.google.com/forum/#!topic/opendatakit/SPuPrrOdAno

Thanks,

--
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

Hi,

I am having a similar problem. Again I am trying to use cascading select questions within a repeat group and the form falls over when trying to enter the second repeat.

I have read that this can be solved using 'current()' but that this isn't functional in XLSForm, which I have used for the form design.

Is it possible to edit the raw XLM code, once the XLSForm is converted, before loading onto an android device?

An example of the XML code I would be looking to add it to is below.

Thanks in advance,

Llewellyn

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>cascading select test</h:title>




Late Start


Rain


Person 2


Person 1


Person 3


Rare Occurrence


Regular Occurrence


Snow


Working Time


Less than 6 weeks old


More than 6 weeks old


Not rework


Could be rework


ECR Work


Normal Work


Supervisor Late


Due to Weather




<new_cascading_select_repeat id="cascading_select_test">















</new_cascading_select_repeat>




static_instance-person-0
person1


static_instance-person-1
person1


static_instance-person-2
person1






static_instance-subcats-0
work
ecr


static_instance-subcats-1
work
normal


static_instance-subcats-2
latestart
supervisor


static_instance-subcats-3
latestart
weather






static_instance-cats-0
work


static_instance-cats-1
latestart






static_instance-subcats2-0
work
ecr
more6


static_instance-subcats2-1
work
ecr
less6


static_instance-subcats2-2
work
normal
rework


static_instance-subcats2-3
work
normal
notrework


static_instance-subcats2-4
latestart
supervisor
regular


static_instance-subcats2-5
latestart
supervisor
rare


static_instance-subcats2-6
latestart
weather
rain


static_instance-subcats2-7
latestart
weather
snow













</h:head>
<h:body>

Study Data

Study ID


Date of Study


Person Conducting Study



Activity


Person

Person 1
person1


Person 2
person1


Person 3
person1



Time at Activity Start


Category

Working Time
work


Late Start
latestart



Subcategory






Subcategory 2







</h:body>
</h:html>

Yes. You can edit the XML and upload that to ODK Aggregate.

Yaw

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

On Thu, Aug 14, 2014 at 5:34 AM, llewellyn.d.kinch@gmail.com wrote:

Hi,

I am having a similar problem. Again I am trying to use cascading select questions within a repeat group and the form falls over when trying to enter the second repeat.

I have read that this can be solved using 'current()' but that this isn't functional in XLSForm, which I have used for the form design.

Is it possible to edit the raw XLM code, once the XLSForm is converted, before loading onto an android device?

An example of the XML code I would be looking to add it to is below.

Thanks in advance,

Llewellyn

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>cascading select test</h:title>




Late Start


Rain


Person 2


Person 1


Person 3


Rare Occurrence


Regular Occurrence


Snow


Working Time


Less than 6 weeks old


More than 6 weeks old


Not rework


Could be rework


ECR Work


Normal Work


Supervisor Late


Due to Weather




<new_cascading_select_repeat id="cascading_select_test">















</new_cascading_select_repeat>




static_instance-person-0
person1


static_instance-person-1
person1


static_instance-person-2
person1






static_instance-subcats-0
work
ecr


static_instance-subcats-1
work
normal


static_instance-subcats-2
latestart
supervisor


static_instance-subcats-3
latestart
weather






static_instance-cats-0
work


static_instance-cats-1
latestart






static_instance-subcats2-0
work
ecr
more6


static_instance-subcats2-1
work
ecr
less6


static_instance-subcats2-2
work
normal
rework


static_instance-subcats2-3
work
normal
notrework


static_instance-subcats2-4
latestart
supervisor
regular


static_instance-subcats2-5
latestart
supervisor
rare


static_instance-subcats2-6
latestart
weather
rain


static_instance-subcats2-7
latestart
weather
snow













</h:head>
<h:body>

Study Data

Study ID


Date of Study


Person Conducting Study



Activity


Person

Person 1
person1


Person 2
person1


Person 3
person1



Time at Activity Start


Category

Working Time
work


Late Start
latestart



Subcategory






Subcategory 2







</h:body>
</h:html>

--
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.

And current() is useable in XLSForm -- instead of writing ${q1}, you can
write current()/....q1 where "...q1" is whatever relative path you need to
use to access the q1 field from whatever field you are currently in.

This is awkward and tedious to get right, but does allow you to continue to
develop your form in XLS without the need to hand-edit the XML.

Here is info from another thread:

I need to add this to our site documentation...

If you look at the generated XML, the way the data is stored is described
by the record with the id="formid" from your file.

e.g.,

<income_section id="aces">
<Household_Income>
<household_income_note/>
<interviewee_sectionH/>
<income_sources jr:template="">
<household_income_source/>
<direct_forest_product_information jr:template="">
<direct_forest_product_note_1/>
<direct_forest_product_note_2/>
<direct_forest_product_note_3/>
<direct_forest_product_note_4/>
<direct_forest_product_type/>
<direct_forest_product_type_other/>
<direct_forest_product_type_specific/>
<direct_forest_product_collection_location/>
<direct_forest_product_collection_location_other/>
<direct_forest_product_distance_hours/>
<direct_forest_product_quantity/>
<direct_forest_product_quantity_unit/>

<direct_forest_product_consumed>0</direct_forest_product_consumed>
<direct_forest_product_consumed_unit/>
<direct_forest_product_sold/>
<direct_forest_product_sold_unit/>
<direct_forest_product_price_per_unit/>
<direct_forest_product_pricing_unit/>
<direct_forest_product_market/>
<direct_forest_product_market_other/>
<direct_forest_products_expenditures_yes_no/>
<direct_forest_products_expenditures jr:template="">
<direct_forest_product_expenditures_note/>
<direct_forest_product_expenditure_type/>
<direct_forest_product_expenditure_quantity/>
<direct_forest_product_expenditure_unit/>
<direct_forest_product_expenditure_repeat_note/>
</direct_forest_products_expenditures>

This describes a list of the field names and their nesting.

Note first that the XLS syntax ${direct_forest_product_expenditure_unit} is
just a shorthand for the expansion of the path from the field within the
down to the named field. I.e., it expands to:

/income_section/Household_Income/income_sources/direct_forest_product_information/direct_forest_products_expenditures/direct_forest_product_expenditure_unit

This is similar to a full directory path in a browser or file browser.

An alternative way of referencing values is a relative-path, using:

  • one dot (.) to refer to the current question, and
  • two dots (..) to refer to that question's parent.

So, for example, if you are in the
${direct_forest_product_expenditure_quantity} question, you could refer to
the 'direct_forest_product_expenditure_unit' value with either:

${direct_forest_product_expenditure_unit}

or

../direct_forest_product_expenditure_unit

But, within repeat groups, the first one (
${direct_forest_product_expenditure_unit} ) does not work when you begin
the 2nd repeat -- it becomes multi-valued, and crashes the form.

==> you MUST use the relative-path syntax when referring to any field
within a repeat group, or, if accessing it from outside the repeat group,
you should use the indexed-repeat() function.

Thus, if you are in the ${direct_forest_product_expenditure_quantity}
question, and want to reference the corresponding
${direct_forest_product_type}, you would need to write

.. (to get up to ${direct_forest_products_expenditures} )
.. (to get up to ${direct_forest_product_information} )
direct_forest_product_type

yielding:

../../direct_forest_product_type

in your formulas.

··· On Thu, Aug 14, 2014 at 9:46 AM, Yaw Anokwa wrote:

Yes. You can edit the XML and upload that to ODK Aggregate.

Yaw

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

On Thu, Aug 14, 2014 at 5:34 AM, llewellyn.d.kinch@gmail.com wrote:

Hi,

I am having a similar problem. Again I am trying to use cascading select
questions within a repeat group and the form falls over when trying to
enter the second repeat.

I have read that this can be solved using 'current()' but that this
isn't functional in XLSForm, which I have used for the form design.

Is it possible to edit the raw XLM code, once the XLSForm is converted,
before loading onto an android device?

An example of the XML code I would be looking to add it to is below.

Thanks in advance,

Llewellyn

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="
http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="
http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>cascading select test</h:title>




Late Start


Rain


Person 2


Person 1


Person 3


Rare Occurrence


Regular Occurrence


Snow


Working Time


Less than 6 weeks old


More than 6 weeks old


Not rework


Could be rework


ECR Work


Normal Work


Supervisor Late


Due to Weather




<new_cascading_select_repeat id="cascading_select_test">















</new_cascading_select_repeat>




static_instance-person-0
person1


static_instance-person-1
person1


static_instance-person-2
person1






static_instance-subcats-0
work
ecr


static_instance-subcats-1
work
normal


static_instance-subcats-2
latestart
supervisor


static_instance-subcats-3
latestart
weather






static_instance-cats-0
work


static_instance-cats-1
latestart






static_instance-subcats2-0
work
ecr
more6


static_instance-subcats2-1
work
ecr
less6


static_instance-subcats2-2
work
normal
rework


static_instance-subcats2-3
work
normal
notrework


static_instance-subcats2-4
latestart
supervisor
regular


static_instance-subcats2-5
latestart
supervisor
rare


static_instance-subcats2-6
latestart
weather
rain


static_instance-subcats2-7
latestart
weather
snow













</h:head>
<h:body>

Study Data

Study ID


Date of Study


Person Conducting Study



Activity


Person

Person 1
person1


Person 2
person1


Person 3
person1



Time at Activity Start


Category

Working Time
work


Late Start
latestart



Subcategory






Subcategory 2







</h:body>
</h:html>

--
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