Reference to label instead of value

Hi all,
I would like to reference to the label of an (categorical) answer instead of value which we do like this ${variable}. I have done a bit of research but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

I don't think there is an easy way to do this. The only way I can think of
would be to make a formula with a bunch of nested "if" statements that
returns the label corresponding to the variable's value. For example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B label',
etc.))
Regards,
-Nathan

··· On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote: > > Hi all, > I would like to reference to the label of an (categorical) answer instead > of value which we do like this ${variable}. I have done a bit of research > but I've not found a clue. > > Does anyway have a solution? > > Thanks. > Trugn > >

Just confirmed that this is impossible (or rather really hard to do).

··· On Tue, Mar 20, 2012 at 09:50, Nathan wrote: > I don't think there is an easy way to do this. The only way I can think of > would be to make a formula with a bunch of nested "if" statements that > returns the label corresponding to the variable's value. For example: > if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B label', > etc.)) > Regards, > -Nathan > > On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote: >> >> Hi all, >> I would like to reference to the label of an (categorical) answer instead >> of value which we do like this ${variable}. I have done a bit of research >> but I've not found a clue. >> >> Does anyway have a solution? >> >> Thanks. >> Trugn > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en

Thanks Nathan and Yaw. In our current project we intend to get around by
making copying labels to values but this is pretty odd. Hope we will have a
better solution in the future.

Trung.

··· On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote: > > Just confirmed that this is impossible (or rather really hard to do). > > On Tue, Mar 20, 2012 at 09:50, Nathan wrote: > > I don't think there is an easy way to do this. The only way I can think > of > > would be to make a formula with a bunch of nested "if" statements that > > returns the label corresponding to the variable's value. For example: > > if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B label', > > etc.)) > > Regards, > > -Nathan > > > > On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote: > >> > >> Hi all, > >> I would like to reference to the label of an (categorical) answer > instead > >> of value which we do like this ${variable}. I have done a bit of > research > >> but I've not found a clue. > >> > >> Does anyway have a solution? > >> > >> Thanks. > >> Trugn > > > > -- > > Post: opendatakit@googlegroups.com > > Unsubscribe: opendatakit+unsubscribe@​googlegroups.com > > Options: http://groups.google.com/​group/opendatakit?hl=en >

There is a pretty straightforward way to do this, actually. If you create
your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label for
the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has to
answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the user
is invisible to the backend engine. It's better to share the things you
want to use than to try to fetch them from the UI layer.

-Clayton

··· On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le wrote:

Thanks Nathan and Yaw. In our current project we intend to get around by
making copying labels to values but this is pretty odd. Hope we will have a
better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can think
of
would be to make a formula with a bunch of nested "if" statements that
returns the label corresponding to the variable's value. For example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical) answer
instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@​googlegroups.comopendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/​group/opendatakit?hl=enhttp://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Clayton is there a workaround for this in xls2forms?

··· On Tuesday, March 27, 2012 12:07:56 AM UTC+8, Clayton Sims wrote: > > There is a pretty straightforward way to do this, actually. If you create > your select field using itemsets, this looks like > > > > > value1 > value2 > .... > > > > > > ... > value 1 label text > > > ... > > > select from the following > > > > > > > > Now anywhere in the app where you want to show the appropriate label for > the selected value in myanswer, you can just use > > jr:itext(/data/myanswer) > > the only thing to be careful of is that you ensure that the user has to > answer the question, since you can't run jr:itext with no value. > > jr:itext(coalesce(/data/myanswer,'somedefaultlabel')) > > would address that, even. > > It's important to remember that in xforms the layer presented to the user > is invisible to the backend engine. It's better to share the things you > want to use than to try to fetch them from the UI layer. > > -Clayton > > On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le <trung...@gmail.com wrote: > >> Thanks Nathan and Yaw. In our current project we intend to get around by >> making copying labels to values but this is pretty odd. Hope we will have a >> better solution in the future. >> >> Trung. >> >> >> On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote: >>> >>> Just confirmed that this is impossible (or rather really hard to do). >>> >>> On Tue, Mar 20, 2012 at 09:50, Nathan <nab...@gmail.com > wrote: >>> > I don't think there is an easy way to do this. The only way I can >>> think of >>> > would be to make a formula with a bunch of nested "if" statements that >>> > returns the label corresponding to the variable's value. For example: >>> > if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B >>> label', >>> > etc.)) >>> > Regards, >>> > -Nathan >>> > >>> > On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote: >>> >> >>> >> Hi all, >>> >> I would like to reference to the label of an (categorical) answer >>> instead >>> >> of value which we do like this ${variable}. I have done a bit of >>> research >>> >> but I've not found a clue. >>> >> >>> >> Does anyway have a solution? >>> >> >>> >> Thanks. >>> >> Trugn >>> > >>> > -- >>> > Post: opend...@googlegroups.com >>> > Unsubscribe: opendatakit...@​googlegroups.com >>> > Options: http://groups.google.com/​group/opendatakit?hl=en >>> >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@googlegroups.com >> Options: http://groups.google.com/group/opendatakit?hl=en >> > >

Clayton,

Your itemset-based solution to fetching labels appears that it should work
with XLSForm -- provided that your option lists have a filter/choice_filter
column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there an
option to pull labels appropriately for select_multiple cases? For example,
you call selected-at() to fetch selection #x, then you want the label that
goes with that particular selection. Is there a way to do that via
jr:itext()?

I'd been planning to implement a selection-label() function to pull the
label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

··· On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims wrote:

There is a pretty straightforward way to do this, actually. If you create
your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label for
the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has to
answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the user
is invisible to the backend engine. It's better to share the things you
want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le trungdangle@gmail.comwrote:

Thanks Nathan and Yaw. In our current project we intend to get around by
making copying labels to values but this is pretty odd. Hope we will have a
better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can
think of
would be to make a formula with a bunch of nested "if" statements that
returns the label corresponding to the variable's value. For example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical) answer
instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

Hi Clayton,
Do you have a suggestion on how this can work where I am populating the choices via external itemset. jr:choice-name() does not seem to work in that case presumably since it is no longer a select1 when working with external itemsets.csv

··· On Monday, March 26, 2012 9:37:56 PM UTC+5:30, Clayton Sims wrote: > There is a pretty straightforward way to do this, actually. If you create your select field using itemsets, this looks like > > > > > > > > value1 > value2 > .... > > > > > > > > > ... > value 1 label text > > > > ... > > > > > > select from the following > > > > > > > > > > > > Now anywhere in the app where you want to show the appropriate label for the selected value in myanswer, you can just use > > > > > jr:itext(/data/myanswer) > > > the only thing to be careful of is that you ensure that the user has to answer the question, since you can't run jr:itext with no value. > > > > > jr:itext(coalesce(/data/myanswer,'somedefaultlabel')) > > > would address that, even. > > > It's important to remember that in xforms the layer presented to the user is invisible to the backend engine. It's better to share the things you want to use than to try to fetch them from the UI layer. > > > > > -Clayton > > > On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le wrote: > > > Thanks Nathan and Yaw. In our current project we intend to get around by making copying labels to values but this is pretty odd. Hope we will have a better solution in the future. > > > > > Trung. > > > > > On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote: > > Just confirmed that this is impossible (or rather really hard to do). > On Tue, Mar 20, 2012 at 09:50, Nathan wrote: > > I don't think there is an easy way to do this. The only way I can think of > > > > would be to make a formula with a bunch of nested "if" statements that > > returns the label corresponding to the variable's value. For example: > > if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B label', > > > > etc.)) > > Regards, > > -Nathan > > > > On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote: > >> > >> Hi all, > >> I would like to reference to the label of an (categorical) answer instead > > > >> of value which we do like this ${variable}. I have done a bit of research > >> but I've not found a clue. > >> > >> Does anyway have a solution? > >> > >> Thanks. > >> Trugn > > > > > > -- > > Post: opend...@googlegroups.com > > Unsubscribe: opendatakit...@​googlegroups.com > > > > Options: http://groups.google.com/​group/opendatakit?hl=en > > > > > > > > > > -- > > Post: opend...@googlegroups.com > > Unsubscribe: opendatakit...@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en

I actually discovered the jr:choice-name() function, which seems to promise
the functionality that I and many others are after. However, when I try it
with a very simple static yes/no select_one, it always fails with a
NullPointerException on validation. It doesn't seem to matter much what I
pass it; it always seems to fail.

Has anybody had any luck with jr:choice-name()?

Thanks,

Chris

··· On Mon, Jun 17, 2013 at 8:44 AM, Christopher Robert wrote:

Clayton,

Your itemset-based solution to fetching labels appears that it should work
with XLSForm -- provided that your option lists have a filter/choice_filter
column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there an
option to pull labels appropriately for select_multiple cases? For example,
you call selected-at() to fetch selection #x, then you want the label that
goes with that particular selection. Is there a way to do that via
jr:itext()?

I'd been planning to implement a selection-label() function to pull the
label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims csims@dimagi.com wrote:

There is a pretty straightforward way to do this, actually. If you create
your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label for
the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has to
answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the user
is invisible to the backend engine. It's better to share the things you
want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le trungdangle@gmail.comwrote:

Thanks Nathan and Yaw. In our current project we intend to get around by
making copying labels to values but this is pretty odd. Hope we will have a
better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can
think of
would be to make a formula with a bunch of nested "if" statements that
returns the label corresponding to the variable's value. For example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical) answer
instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

I don't see that in the JR source tree. Is that perhaps an extension added
via a IFunctionHandler in whatever system you're looking at?

··· On Fri, Jun 21, 2013 at 6:19 AM, Christopher Robert wrote:

I actually discovered the jr:choice-name() function, which seems to
promise the functionality that I and many others are after. However, when I
try it with a very simple static yes/no select_one, it always fails with a
NullPointerException on validation. It doesn't seem to matter much what I
pass it; it always seems to fail.

Has anybody had any luck with jr:choice-name()?

Thanks,

Chris

On Mon, Jun 17, 2013 at 8:44 AM, Christopher Robert <crobert@surveycto.com wrote:

Clayton,

Your itemset-based solution to fetching labels appears that it should
work with XLSForm -- provided that your option lists have a
filter/choice_filter column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there an
option to pull labels appropriately for select_multiple cases? For example,
you call selected-at() to fetch selection #x, then you want the label that
goes with that particular selection. Is there a way to do that via
jr:itext()?

I'd been planning to implement a selection-label() function to pull the
label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims csims@dimagi.com wrote:

There is a pretty straightforward way to do this, actually. If you
create your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label for
the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has to
answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the
user is invisible to the backend engine. It's better to share the things
you want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le trungdangle@gmail.comwrote:

Thanks Nathan and Yaw. In our current project we intend to get around
by making copying labels to values but this is pretty odd. Hope we will
have a better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can
think of
would be to make a formula with a bunch of nested "if" statements
that
returns the label corresponding to the variable's value. For example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical) answer
instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--

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/groups/opt_out.

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

Mitch, I have to admit, for a brief moment I questioned my own sanity, and
wondered whether it was something I'd myself written. But no, see:

https://bitbucket.org/javarosa/javarosa/commits/24ed57dcff395ac1bc739b1058e7ce890761f224

It's also in the FormDef.java in your JavaRosa branch. It's just not at all
in the normal place for such things..!

Chris

··· On Fri, Jun 21, 2013 at 6:25 PM, Mitch Sundt wrote:

I don't see that in the JR source tree. Is that perhaps an extension
added via a IFunctionHandler in whatever system you're looking at?

On Fri, Jun 21, 2013 at 6:19 AM, Christopher Robert <crobert@surveycto.com wrote:

I actually discovered the jr:choice-name() function, which seems to
promise the functionality that I and many others are after. However, when I
try it with a very simple static yes/no select_one, it always fails with a
NullPointerException on validation. It doesn't seem to matter much what I
pass it; it always seems to fail.

Has anybody had any luck with jr:choice-name()?

Thanks,

Chris

On Mon, Jun 17, 2013 at 8:44 AM, Christopher Robert < crobert@surveycto.com> wrote:

Clayton,

Your itemset-based solution to fetching labels appears that it should
work with XLSForm -- provided that your option lists have a
filter/choice_filter column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there an
option to pull labels appropriately for select_multiple cases? For example,
you call selected-at() to fetch selection #x, then you want the label that
goes with that particular selection. Is there a way to do that via
jr:itext()?

I'd been planning to implement a selection-label() function to pull the
label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims csims@dimagi.com wrote:

There is a pretty straightforward way to do this, actually. If you
create your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label
for the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has to
answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the
user is invisible to the backend engine. It's better to share the things
you want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le trungdangle@gmail.comwrote:

Thanks Nathan and Yaw. In our current project we intend to get around
by making copying labels to values but this is pretty odd. Hope we will
have a better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can
think of
would be to make a formula with a bunch of nested "if" statements
that
returns the label corresponding to the variable's value. For
example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical) answer
instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--

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/groups/opt_out.

--
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/groups/opt_out.

Wow. OK. I never, ever, knew about this...

I've updated the documentation on the bindings page

with the usage information.

··· On Fri, Jun 21, 2013 at 9:44 AM, Christopher Robert wrote:

Mitch, I have to admit, for a brief moment I questioned my own sanity, and
wondered whether it was something I'd myself written. But no, see:

https://bitbucket.org/javarosa/javarosa/commits/24ed57dcff395ac1bc739b1058e7ce890761f224

It's also in the FormDef.java in your JavaRosa branch. It's just not at
all in the normal place for such things..!

Chris

On Fri, Jun 21, 2013 at 6:25 PM, Mitch Sundt mitchellsundt@gmail.comwrote:

I don't see that in the JR source tree. Is that perhaps an extension
added via a IFunctionHandler in whatever system you're looking at?

On Fri, Jun 21, 2013 at 6:19 AM, Christopher Robert < crobert@surveycto.com> wrote:

I actually discovered the jr:choice-name() function, which seems to
promise the functionality that I and many others are after. However, when I
try it with a very simple static yes/no select_one, it always fails with a
NullPointerException on validation. It doesn't seem to matter much what I
pass it; it always seems to fail.

Has anybody had any luck with jr:choice-name()?

Thanks,

Chris

On Mon, Jun 17, 2013 at 8:44 AM, Christopher Robert < crobert@surveycto.com> wrote:

Clayton,

Your itemset-based solution to fetching labels appears that it should
work with XLSForm -- provided that your option lists have a
filter/choice_filter column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there an
option to pull labels appropriately for select_multiple cases? For example,
you call selected-at() to fetch selection #x, then you want the label that
goes with that particular selection. Is there a way to do that via
jr:itext()?

I'd been planning to implement a selection-label() function to pull the
label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims csims@dimagi.com wrote:

There is a pretty straightforward way to do this, actually. If you
create your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label
for the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has
to answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the
user is invisible to the backend engine. It's better to share the things
you want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le trungdangle@gmail.comwrote:

Thanks Nathan and Yaw. In our current project we intend to get around
by making copying labels to values but this is pretty odd. Hope we will
have a better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can
think of
would be to make a formula with a bunch of nested "if" statements
that
returns the label corresponding to the variable's value. For
example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical) answer
instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--

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/groups/opt_out.

--
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/groups/opt_out.

--

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/groups/opt_out.

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

But, Mitch, two things:

  1. There seems to be a NullPointerException whenever you try to pass a
    jr:choice-name() through ODK_Validate.

  2. The XPath in the second parameter has to be surrounded by quotes so that
    it's passed in as a string, otherwise you get a "Parse error in XPath path"
    exception.

I tested with a single and two languages (so with a very basic itemset
case). I'll see about fixing the NullPointerException so that it will work
via XLSForms (which have to pass through ODK_Validate). If you revise the
bindings page to have quotes around the XPath, then maybe we'll have a
solution.

Thanks,

Chris

··· On Fri, Jun 21, 2013 at 10:02 PM, Mitch Sundt wrote:

Wow. OK. I never, ever, knew about this...

I've updated the documentation on the bindings page
http://opendatakit.org/help/form-design/binding/
with the usage information.

On Fri, Jun 21, 2013 at 9:44 AM, Christopher Robert < chrislrobert@gmail.com> wrote:

Mitch, I have to admit, for a brief moment I questioned my own sanity,
and wondered whether it was something I'd myself written. But no, see:

https://bitbucket.org/javarosa/javarosa/commits/24ed57dcff395ac1bc739b1058e7ce890761f224

It's also in the FormDef.java in your JavaRosa branch. It's just not at
all in the normal place for such things..!

Chris

On Fri, Jun 21, 2013 at 6:25 PM, Mitch Sundt mitchellsundt@gmail.comwrote:

I don't see that in the JR source tree. Is that perhaps an extension
added via a IFunctionHandler in whatever system you're looking at?

On Fri, Jun 21, 2013 at 6:19 AM, Christopher Robert < crobert@surveycto.com> wrote:

I actually discovered the jr:choice-name() function, which seems to
promise the functionality that I and many others are after. However, when I
try it with a very simple static yes/no select_one, it always fails with a
NullPointerException on validation. It doesn't seem to matter much what I
pass it; it always seems to fail.

Has anybody had any luck with jr:choice-name()?

Thanks,

Chris

On Mon, Jun 17, 2013 at 8:44 AM, Christopher Robert < crobert@surveycto.com> wrote:

Clayton,

Your itemset-based solution to fetching labels appears that it should
work with XLSForm -- provided that your option lists have a
filter/choice_filter column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there an
option to pull labels appropriately for select_multiple cases? For example,
you call selected-at() to fetch selection #x, then you want the label that
goes with that particular selection. Is there a way to do that via
jr:itext()?

I'd been planning to implement a selection-label() function to pull
the label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims csims@dimagi.comwrote:

There is a pretty straightforward way to do this, actually. If you
create your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label
for the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has
to answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the
user is invisible to the backend engine. It's better to share the things
you want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le <trungdangle@gmail.com wrote:

Thanks Nathan and Yaw. In our current project we intend to get
around by making copying labels to values but this is pretty odd. Hope we
will have a better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to
do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I can
think of
would be to make a formula with a bunch of nested "if" statements
that
returns the label corresponding to the variable's value. For
example:
if(${variable}='a_value', 'A label', if(${variable}='b_value', 'B
label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical)
answer instead
of value which we do like this ${variable}. I have done a bit of
research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--

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/groups/opt_out.

--
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/groups/opt_out.

--

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/groups/opt_out.

--
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/groups/opt_out.

I've filed https://code.google.com/p/opendatakit/issues/detail?id=854 with
a fix for the exception. Then I think that jr:choice-name() is actually
ready to use.

Thanks,

Chris

··· On Sat, Jun 22, 2013 at 9:20 AM, Christopher Robert wrote:

But, Mitch, two things:

  1. There seems to be a NullPointerException whenever you try to pass a
    jr:choice-name() through ODK_Validate.

  2. The XPath in the second parameter has to be surrounded by quotes so
    that it's passed in as a string, otherwise you get a "Parse error in XPath
    path" exception.

I tested with a single and two languages (so with a very basic itemset
case). I'll see about fixing the NullPointerException so that it will work
via XLSForms (which have to pass through ODK_Validate). If you revise the
bindings page to have quotes around the XPath, then maybe we'll have a
solution.

Thanks,

Chris

On Fri, Jun 21, 2013 at 10:02 PM, Mitch Sundt mitchellsundt@gmail.comwrote:

Wow. OK. I never, ever, knew about this...

I've updated the documentation on the bindings page
http://opendatakit.org/help/form-design/binding/
with the usage information.

On Fri, Jun 21, 2013 at 9:44 AM, Christopher Robert < chrislrobert@gmail.com> wrote:

Mitch, I have to admit, for a brief moment I questioned my own sanity,
and wondered whether it was something I'd myself written. But no, see:

https://bitbucket.org/javarosa/javarosa/commits/24ed57dcff395ac1bc739b1058e7ce890761f224

It's also in the FormDef.java in your JavaRosa branch. It's just not at
all in the normal place for such things..!

Chris

On Fri, Jun 21, 2013 at 6:25 PM, Mitch Sundt mitchellsundt@gmail.comwrote:

I don't see that in the JR source tree. Is that perhaps an extension
added via a IFunctionHandler in whatever system you're looking at?

On Fri, Jun 21, 2013 at 6:19 AM, Christopher Robert < crobert@surveycto.com> wrote:

I actually discovered the jr:choice-name() function, which seems to
promise the functionality that I and many others are after. However, when I
try it with a very simple static yes/no select_one, it always fails with a
NullPointerException on validation. It doesn't seem to matter much what I
pass it; it always seems to fail.

Has anybody had any luck with jr:choice-name()?

Thanks,

Chris

On Mon, Jun 17, 2013 at 8:44 AM, Christopher Robert < crobert@surveycto.com> wrote:

Clayton,

Your itemset-based solution to fetching labels appears that it should
work with XLSForm -- provided that your option lists have a
filter/choice_filter column so that they are coded into the XML as itemsets.

The solution seems oriented, however, to select_one cases. Is there
an option to pull labels appropriately for select_multiple cases? For
example, you call selected-at() to fetch selection #x, then you want the
label that goes with that particular selection. Is there a way to do that
via jr:itext()?

I'd been planning to implement a selection-label() function to pull
the label associated with a current selection, but obviously I will only
implement that if there is no existing method. If there is an existing
method, then I can focus on finding a way to make it easy enough that it's
accessible to most (XLSForm) users.

Thanks very much,

Chris

On Mon, Mar 26, 2012 at 6:07 PM, Clayton Sims csims@dimagi.comwrote:

There is a pretty straightforward way to do this, actually. If you
create your select field using itemsets, this looks like

value1 value2 .... ... value 1 label text

...

select from the following

Now anywhere in the app where you want to show the appropriate label
for the selected value in myanswer, you can just use

jr:itext(/data/myanswer)

the only thing to be careful of is that you ensure that the user has
to answer the question, since you can't run jr:itext with no value.

jr:itext(coalesce(/data/myanswer,'somedefaultlabel'))

would address that, even.

It's important to remember that in xforms the layer presented to the
user is invisible to the backend engine. It's better to share the things
you want to use than to try to fetch them from the UI layer.

-Clayton

On Fri, Mar 23, 2012 at 4:36 PM, Trung Dang Le < trungdangle@gmail.com> wrote:

Thanks Nathan and Yaw. In our current project we intend to get
around by making copying labels to values but this is pretty odd. Hope we
will have a better solution in the future.

Trung.

On Friday, March 23, 2012 8:06:43 PM UTC+1, Yaw Anokwa wrote:

Just confirmed that this is impossible (or rather really hard to
do).

On Tue, Mar 20, 2012 at 09:50, Nathan nabreit@gmail.com wrote:

I don't think there is an easy way to do this. The only way I
can think of
would be to make a formula with a bunch of nested "if"
statements that
returns the label corresponding to the variable's value. For
example:
if(${variable}='a_value', 'A label', if(${variable}='b_value',
'B label',
etc.))
Regards,
-Nathan

On Sunday, March 18, 2012 8:38:50 PM UTC-7, Trung Dang Le wrote:

Hi all,
I would like to reference to the label of an (categorical)
answer instead
of value which we do like this ${variable}. I have done a bit
of research
but I've not found a clue.

Does anyway have a solution?

Thanks.
Trugn

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--

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/groups/opt_out.

--
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/groups/opt_out.

--

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/groups/opt_out.

--
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/groups/opt_out.

Is there a solution to this problem now for a select_multiple question in a multilingual survey?

Hi @dbk
What exactly do you want to achieve?

Exactly what the first poster in this thread wrote... "I would like to reference to the label of an (categorical) answer instead of value which we do like this ${variable}". I have since figured it out. Thanks.

For others looking for the solution, it's to use jr:choice-name(). More at https://docs.getodk.org/form-operators-functions/#jr:choice-name.

1 Like