The core library that many of the ODK tools are built around. It's written in Java, implements the ODK XForms spec, and runs on mobile devices and cloud servers. ✨🏗✨
Other
54
stars
107
forks
source link
Error message for nodeset returned when single node expected is generally unhelpful #700
When a nodeset is returned but a single node is expected, the error message says "This field is repeated:" and "You may need to use the indexed-repeat() function to specify which value you want".
The most common case I see this error in is when a predicate returns multiple items for an expression used in a context that requires a single value. Another common case is trying to access a field in a repeat from outside the repeat. The intent is often to use some kind of aggregating function like sum.
The indexed-repeat hint is not useful in either of those cases. It only really applies to parallel repeats. Even then, we try to nudge form creators towards using raw XPath expressions over indexed-repeat.
I wrote an expression to look up a person by household id when I intended to look them up by member id. There are multiple people in the same household so I got this error.
When a nodeset is returned but a single node is expected, the error message says "This field is repeated:" and "You may need to use the indexed-repeat() function to specify which value you want".
The most common case I see this error in is when a predicate returns multiple items for an expression used in a context that requires a single value. Another common case is trying to access a field in a repeat from outside the repeat. The intent is often to use some kind of aggregating function like
sum
.The
indexed-repeat
hint is not useful in either of those cases. It only really applies to parallel repeats. Even then, we try to nudge form creators towards using raw XPath expressions overindexed-repeat
.