Your change would work as long as you never jumped back into the form via
the Hierarchy view. Otherwise, the size()-1 would be referring to the last
group entered, and not the group that is the true parent of the nested
group you're in.
Mitch
···
On Fri, Sep 21, 2012 at 3:55 PM, wrote:
I'd like to be able to run calculations on a form and do them within a
repeat. When going to the second repeat item on ODK Collect, JavaRosa has a
problem with trying to figure out what node to work with:
XPath Evaluation: type mismatch
nodeset has more than one node [...]; cannot convert to a value
A quick dive into JavaRosa and I notice that I can change this function:
org.javarosa.xpath.XPathNodeset.java:
public Object unpack () {
if (size() == 0) {
return XPathPathExpr.unpackValue(null);
} else {
return getValAt(size()-1);
}
}
and everything will work properly. I figured there would be an issue when
going back and editing the form, but none found. Is there a reason why this
wouldn't be a fix for doing calculations within repeats? I'm sure I'm
missing something here but I can't seem to find where this will cause an
issue. Let me know if you find an issue with this.
Your change would work as long as you never jumped back into the form via
the Hierarchy view. Otherwise, the size()-1 would be referring to the last
group entered, and not the group that is the true parent of the nested
group you're in.
I'd like to be able to run calculations on a form and do them within a
repeat. When going to the second repeat item on ODK Collect, JavaRosa has a
problem with trying to figure out what node to work with:
XPath Evaluation: type mismatch
nodeset has more than one node [...]; cannot convert to a value
A quick dive into JavaRosa and I notice that I can change this function:
org.javarosa.xpath.XPathNodeset.java:
public Object unpack () {
if (size() == 0) {
return XPathPathExpr.unpackValue(null);
} else {
return getValAt(size()-1);
}
}
and everything will work properly. I figured there would be an issue when
going back and editing the form, but none found. Is there a reason why this
wouldn't be a fix for doing calculations within repeats? I'm sure I'm
missing something here but I can't seem to find where this will cause an
issue. Let me know if you find an issue with this.
I thought that is where I would find the problem but even after navigating
back it is still working fine on my version...Odd but oh well, I knew
something wasn't right here. I'll see what I can do to fully address the
issue and submit a patch.
Thanks again,
Behr
···
On Friday, September 21, 2012 5:21:16 PM UTC-6, Mitch wrote:
>
> I believe it is a more serious problem with XPath evaluation. See
> http://groups.google.com/group/opendatakit/browse_thread/thread/48fb8faeb39d027a/ff0f9bd7d175fceb?lnk=gst&q=xpath+evaluation#ff0f9bd7d175fceb
>
> Your change would work as long as you never jumped back into the form via
> the Hierarchy view. Otherwise, the size()-1 would be referring to the last
> group entered, and not the group that is the true parent of the nested
> group you're in.
>
> Mitch
>
> On Fri, Sep 21, 2012 at 3:55 PM, <behrat...@gmail.com >wrote:
>
>> I'd like to be able to run calculations on a form and do them within a
>> repeat. When going to the second repeat item on ODK Collect, JavaRosa has a
>> problem with trying to figure out what node to work with:
>>
>> XPath Evaluation: type mismatch
>> nodeset has more than one node [...]; cannot convert to a value
>>
>> A quick dive into JavaRosa and I notice that I can change this function:
>>
>> org.javarosa.xpath.XPathNodeset.java:
>>
>> public Object unpack () {
>> if (size() == 0) {
>> return XPathPathExpr.unpackValue(null);
>> } else {
>> return getValAt(size()-1);
>> }
>> }
>>
>> and everything will work properly. I figured there would be an issue when
>> going back and editing the form, but none found. Is there a reason why this
>> wouldn't be a fix for doing calculations within repeats? I'm sure I'm
>> missing something here but I can't seem to find where this will cause an
>> issue. Let me know if you find an issue with this.
>>
>> Thanks,
>>
>> Behr
>>
>
>
>
> --
> Mitch Sundt
> Software Engineer
> University of Washington
> mitche...@gmail.com
>