Reference Question

Hello Yall!
I am developing a complex ODK form. What I need is help with something I
think is small, but just cannot figure it out.

So I have several group, where each group has a number of questions.
However, they are about 2 or 3 questions in one group that is required in
another group e.g Total Population of the community - I need to make
reference back to that number that would have been entered initially when
the form started - how can I reference that field although I am outside of
the original group that it was declared in.

Thanks
Rox

··· --

"Like a camera I use the negative to develop..uDig"
"Success is the ability to go from one failure to another with no loss of
enthusiasm"
---------------------------------------------------------------------------------------------------------->

Roxroy K. Bollers
GIS & IT Service Provider
tel. 592.685.2737
.........................................................
Follow Us On
Facebook http://www.facebook.com/OutSourceRox
Google+ https://plus.google.com/114064153117817313312
Twitter: @drbollers http://www.twitter.com/drbollers

If you are using XLSForm, and the groups are not repeat groups, you would
just use ${fieldname} and it would be transformed into the appropriate
XPath expression for that field.

To understand XPath expressions, you need to understand how groups affect
the XML file that is generated by whatever design tool you are using. The
Sample Excel file (available here: https://opendatakit.org/use/xlsform/ )
converts to an XML file that has a submission instance structure (you can
open the XML file that is generated and look for the section of
the file, which defines the submission instance structure):

  <instance>
    <sample_xlsform id="sample">
      <some_text/>
      <text_image_audio_video_test/>
      <a_integer>123</a_integer>
      <a_decimal/>
      <calculate/>
      <calculate_test_output/>
      <select_example/>
      <required_text/>
      <acknowledge_test/>
      <skip_example/>
      <skipable_question/>
      <repeat_test jr:template="">
        <repeating_question/>
      </repeat_test>
      <group_test>
        <field_list_note/>
        <select_multiple_1/>
        <select_multiple_2/>
      </group_test>
      <table_list_example>
        <generated_table_list_label_21/>
        <reserved_name_for_field_list_labels_22/>
        <table_list_question_1/>
        <table_list_question_2/>
      </table_list_example>
      <select_appearance_note/>
      <labeled_select_group>
        <label_test/>
        <list-nolabel_test/>
      </labeled_select_group>
      <compact_test/>
      <data_types_note/>
      <date_test/>
      <time_test/>
      <datetime_test/>
      <geopoint_test/>
      <barcode_test/>
      <image_test/>
      <audio_test/>
      <video_test/>
      <metadata_note/>
      <start/>
      <start_test_output/>
      <end/>
      <end_test_output/>
      <today/>
      <today_test_output/>
      <deviceid/>
      <deviceid_test_output/>
      <simserial/>
      <simserial_test_output/>
      <phonenumber/>
      <phonenumber_test_output/>
      <meta>
        <instanceID/>
      </meta>
    </sample_xlsform>
  </instance>

Read up on XML to understand how to read this. The "root node" of the data
submitted from ODK Collect is the node within the section --
<sample_xlsform> in this case. That name is based upon the filename that
you send to XLSForm. If you change the filename, the "root node" changes
and it is a different form.

The above form contains several groups (group_test, table_list_example,
labeled_select_group, meta) and one repeat group (repeat_test).

To reference fields using XPath expressions, you construct a slash
(/)-separated path to the field, starting with the "root node" of the form
(e.g., /sample_xlsform/group_test/select_multiple_1) OR you can use an
XPath expression that is relative to the current field by beginning the
path with "." (a.k.a. myself) or ".." (a.k.a. my enclosing group). This is
why constraints can be written as, e.g., " . < 6 or . > 10 " -- the "."
stands for myself (the value in the field that has the constraint applied
to it).

Relative paths generally begin with "../" and the "../" can be repeated to
go to the enclosing group of the enclosing group, etc.

For the sample form above, if you wanted to refer to the value of
select_multiple_1
from within the field label_test, you would use

../../group_test/select_multiple_1

this breaks down, when starting from
/sample_xlsform/labeled_select_group/label_test
:

.. -- refers to /sample_xlsform/labeled_select_group

../.. -- refers to /sample_xlsform

../../group_test-- refers to /sample_xlsform/group_test

../../group_test/select_multiple_1-- refers to /sample_xlsform/group_test/
select_multiple_1

··· ================= Mitch

On Thu, Apr 21, 2016 at 8:33 PM, Roxroy Bollers rkbollers@gmail.com wrote:

Hello Yall!
I am developing a complex ODK form. What I need is help with something I
think is small, but just cannot figure it out.

So I have several group, where each group has a number of questions.
However, they are about 2 or 3 questions in one group that is required in
another group e.g Total Population of the community - I need to make
reference back to that number that would have been entered initially when
the form started - how can I reference that field although I am outside of
the original group that it was declared in.

Thanks
Rox

--


"Like a camera I use the negative to develop..uDig"
"Success is the ability to go from one failure to another with no loss of
enthusiasm"

---------------------------------------------------------------------------------------------------------->

Roxroy K. Bollers
GIS & IT Service Provider
tel. 592.685.2737
.........................................................
Follow Us On
Facebook http://www.facebook.com/OutSourceRox
Google+ https://plus.google.com/114064153117817313312
Twitter: @drbollers http://www.twitter.com/drbollers

--

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

And I have added this to the Form Design documentation, as it is a
long-overdue write-up.

Included is a slick example form that goes a bit crazy with all of this:

https://opendatakit.org/help/form-design/#xpath_expressions

··· On Fri, Apr 22, 2016 at 11:06 AM, Mitch Sundt wrote:

If you are using XLSForm, and the groups are not repeat groups, you would
just use ${fieldname} and it would be transformed into the appropriate
XPath expression for that field.

To understand XPath expressions, you need to understand how groups affect
the XML file that is generated by whatever design tool you are using. The
Sample Excel file (available here: https://opendatakit.org/use/xlsform/ )
converts to an XML file that has a submission instance structure (you can
open the XML file that is generated and look for the section of
the file, which defines the submission instance structure):

  <instance>
    <sample_xlsform id="sample">
      <some_text/>
      <text_image_audio_video_test/>
      <a_integer>123</a_integer>
      <a_decimal/>
      <calculate/>
      <calculate_test_output/>
      <select_example/>
      <required_text/>
      <acknowledge_test/>
      <skip_example/>
      <skipable_question/>
      <repeat_test jr:template="">
        <repeating_question/>
      </repeat_test>
      <group_test>
        <field_list_note/>
        <select_multiple_1/>
        <select_multiple_2/>
      </group_test>
      <table_list_example>
        <generated_table_list_label_21/>
        <reserved_name_for_field_list_labels_22/>
        <table_list_question_1/>
        <table_list_question_2/>
      </table_list_example>
      <select_appearance_note/>
      <labeled_select_group>
        <label_test/>
        <list-nolabel_test/>
      </labeled_select_group>
      <compact_test/>
      <data_types_note/>
      <date_test/>
      <time_test/>
      <datetime_test/>
      <geopoint_test/>
      <barcode_test/>
      <image_test/>
      <audio_test/>
      <video_test/>
      <metadata_note/>
      <start/>
      <start_test_output/>
      <end/>
      <end_test_output/>
      <today/>
      <today_test_output/>
      <deviceid/>
      <deviceid_test_output/>
      <simserial/>
      <simserial_test_output/>
      <phonenumber/>
      <phonenumber_test_output/>
      <meta>
        <instanceID/>
      </meta>
    </sample_xlsform>
  </instance>

Read up on XML to understand how to read this. The "root node" of the data
submitted from ODK Collect is the node within the section --
<sample_xlsform> in this case. That name is based upon the filename that
you send to XLSForm. If you change the filename, the "root node" changes
and it is a different form.

The above form contains several groups (group_test, table_list_example,
labeled_select_group, meta) and one repeat group (repeat_test).

To reference fields using XPath expressions, you construct a slash
(/)-separated path to the field, starting with the "root node" of the form
(e.g., /sample_xlsform/group_test/select_multiple_1) OR you can use an
XPath expression that is relative to the current field by beginning the
path with "." (a.k.a. myself) or ".." (a.k.a. my enclosing group). This is
why constraints can be written as, e.g., " . < 6 or . > 10 " -- the "."
stands for myself (the value in the field that has the constraint applied
to it).

Relative paths generally begin with "../" and the "../" can be repeated to
go to the enclosing group of the enclosing group, etc.

For the sample form above, if you wanted to refer to the value of select_multiple_1
from within the field label_test, you would use

../../group_test/select_multiple_1

this breaks down, when starting from /sample_xlsform/labeled_select_group/label_test
:

.. -- refers to /sample_xlsform/labeled_select_group

../.. -- refers to /sample_xlsform

../../group_test-- refers to /sample_xlsform/group_test

../../group_test/select_multiple_1-- refers to /sample_xlsform/
group_test/select_multiple_1

=================
Mitch

On Thu, Apr 21, 2016 at 8:33 PM, Roxroy Bollers rkbollers@gmail.com wrote:

Hello Yall!
I am developing a complex ODK form. What I need is help with something I
think is small, but just cannot figure it out.

So I have several group, where each group has a number of questions.
However, they are about 2 or 3 questions in one group that is required in
another group e.g Total Population of the community - I need to make
reference back to that number that would have been entered initially when
the form started - how can I reference that field although I am outside of
the original group that it was declared in.

Thanks
Rox

--


"Like a camera I use the negative to develop..uDig"
"Success is the ability to go from one failure to another with no loss of
enthusiasm"

---------------------------------------------------------------------------------------------------------->

Roxroy K. Bollers
GIS & IT Service Provider
tel. 592.685.2737
.........................................................
Follow Us On
Facebook http://www.facebook.com/OutSourceRox
Google+ https://plus.google.com/114064153117817313312
Twitter: @drbollers http://www.twitter.com/drbollers

--

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 Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Thanks Mitch!
Will give this a go.

Rox.

···

On 22 April 2016 at 15:35, Mitch Sundt mitchellsundt@gmail.com wrote:

And I have added this to the Form Design documentation, as it is a
long-overdue write-up.

Included is a slick example form that goes a bit crazy with all of this:

https://opendatakit.org/help/form-design/#xpath_expressions

On Fri, Apr 22, 2016 at 11:06 AM, Mitch Sundt mitchellsundt@gmail.com wrote:

If you are using XLSForm, and the groups are not repeat groups, you would
just use ${fieldname} and it would be transformed into the appropriate
XPath expression for that field.

To understand XPath expressions, you need to understand how groups affect
the XML file that is generated by whatever design tool you are using. The
Sample Excel file (available here: https://opendatakit.org/use/xlsform/
) converts to an XML file that has a submission instance structure (you can
open the XML file that is generated and look for the section of
the file, which defines the submission instance structure):

  <instance>
    <sample_xlsform id="sample">
      <some_text/>
      <text_image_audio_video_test/>
      <a_integer>123</a_integer>
      <a_decimal/>
      <calculate/>
      <calculate_test_output/>
      <select_example/>
      <required_text/>
      <acknowledge_test/>
      <skip_example/>
      <skipable_question/>
      <repeat_test jr:template="">
        <repeating_question/>
      </repeat_test>
      <group_test>
        <field_list_note/>
        <select_multiple_1/>
        <select_multiple_2/>
      </group_test>
      <table_list_example>
        <generated_table_list_label_21/>
        <reserved_name_for_field_list_labels_22/>
        <table_list_question_1/>
        <table_list_question_2/>
      </table_list_example>
      <select_appearance_note/>
      <labeled_select_group>
        <label_test/>
        <list-nolabel_test/>
      </labeled_select_group>
      <compact_test/>
      <data_types_note/>
      <date_test/>
      <time_test/>
      <datetime_test/>
      <geopoint_test/>
      <barcode_test/>
      <image_test/>
      <audio_test/>
      <video_test/>
      <metadata_note/>
      <start/>
      <start_test_output/>
      <end/>
      <end_test_output/>
      <today/>
      <today_test_output/>
      <deviceid/>
      <deviceid_test_output/>
      <simserial/>
      <simserial_test_output/>
      <phonenumber/>
      <phonenumber_test_output/>
      <meta>
        <instanceID/>
      </meta>
    </sample_xlsform>
  </instance>

Read up on XML to understand how to read this. The "root node" of the
data submitted from ODK Collect is the node within the section
-- <sample_xlsform> in this case. That name is based upon the filename that
you send to XLSForm. If you change the filename, the "root node" changes
and it is a different form.

The above form contains several groups (group_test, table_list_example,
labeled_select_group, meta) and one repeat group (repeat_test).

To reference fields using XPath expressions, you construct a slash
(/)-separated path to the field, starting with the "root node" of the form
(e.g., /sample_xlsform/group_test/select_multiple_1) OR you can use an
XPath expression that is relative to the current field by beginning the
path with "." (a.k.a. myself) or ".." (a.k.a. my enclosing group). This is
why constraints can be written as, e.g., " . < 6 or . > 10 " -- the "."
stands for myself (the value in the field that has the constraint applied
to it).

Relative paths generally begin with "../" and the "../" can be repeated
to go to the enclosing group of the enclosing group, etc.

For the sample form above, if you wanted to refer to the value of select_multiple_1
from within the field label_test, you would use

../../group_test/select_multiple_1

this breaks down, when starting from /sample_xlsform/
labeled_select_group/label_test :

.. -- refers to /sample_xlsform/labeled_select_group

../.. -- refers to /sample_xlsform

../../group_test-- refers to /sample_xlsform/group_test

../../group_test/select_multiple_1-- refers to /sample_xlsform/
group_test/select_multiple_1

=================
Mitch

On Thu, Apr 21, 2016 at 8:33 PM, Roxroy Bollers rkbollers@gmail.com wrote:

Hello Yall!
I am developing a complex ODK form. What I need is help with something I
think is small, but just cannot figure it out.

So I have several group, where each group has a number of questions.
However, they are about 2 or 3 questions in one group that is required in
another group e.g Total Population of the community - I need to make
reference back to that number that would have been entered initially when
the form started - how can I reference that field although I am outside of
the original group that it was declared in.

Thanks
Rox

--


"Like a camera I use the negative to develop..uDig"
"Success is the ability to go from one failure to another with no loss
of enthusiasm"

---------------------------------------------------------------------------------------------------------->

Roxroy K. Bollers
GIS & IT Service Provider
tel. 592.685.2737
.........................................................
Follow Us On
Facebook http://www.facebook.com/OutSourceRox
Google+ https://plus.google.com/114064153117817313312
Twitter: @drbollers http://www.twitter.com/drbollers

--

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 Sundt
Software Engineer
University of Washington
mitchellsundt@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.

--


"Like a camera I use the negative to develop..uDig"
"Success is the ability to go from one failure to another with no loss of
enthusiasm"
---------------------------------------------------------------------------------------------------------->

Roxroy K. Bollers
GIS & IT Service Provider
tel. 592.685.2737
.........................................................
Follow Us On
Facebook http://www.facebook.com/OutSourceRox
Google+ https://plus.google.com/114064153117817313312
Twitter: @drbollers http://www.twitter.com/drbollers