I have a kobo form that I cannot finalise due to the following error message:
“XPath Evaluation: type mismatch. This field is repeated”. I have uploaded an image with the error.
I have used the online validation tools to make sure there are no errors with the xsl form that was used to create the survey, and it has not identified any errors. Can anyone please advise on how to either 1) fix the form so that it can be finalised, or 2) “force” finalise the forms that are already completed - we already used these forms to collect lots of data.
Unfortunately this site won’t allow me to upload the original xsl form with this post.
Welcome to the community, @danielh382! Have you validated your XLSForm through this online validator? The online validator should help you identify syntax issues if any present within your XLSForm.
You may need to check the variables and expressions used in the repeat group. Try removing them and applying them again to see how it behaves.
Or maybe have a look at these community posts that should help you learn more about the indexed-repeat function.
Hi @Kal_Lam. I have indeed validated the form with the online validator and I didn’t come up with any syntax issues. Looking at other posts on this forum, it seems that this specific type of error is often missed in the online validator.
Thank you very much for the advice concerning the “repeat group” expressions. I will follow your advice by removing and re-adding them. I’ll follow back up when I have tried this.
Thank you very much for the advice, much appreciated!
@Kal_Lam Unfortunately, removing and re-adding the repeat groups did not fix the problem and I am still getting the same error message. Is there anyway that I can upload the xsl file for you to check everything is correct?
Can you please try re-running your form under the latest KoboCollect v2024.2.4. I was able to deploy your above form and successfully fill it in and submit from KoboCollect. I am unable to reproduce what you are seeing in either KoboCollect mobile app nor Enketo web form.
FWIW I didn’t notice anything untoward with your form, although it is quite lengthy and complex. I did notice however an apparent typo; this should probably be ${P1}. But I dont think this would be causing any issue.
Basically, this error often happens when you inadvertently try to reference a field inside a repeat from outside the repeat. When you are inside the repeat its fine to reference other values also inside the repeat, since it naturally defaults to using the current repeat iteration you are in. But when you are outside the repeat and want to reference a value inside the repeat, it doesn’t know which iteration to pull the value out of. Hence the recommended usage of indexed-repeat() function.
But I didnt see anywhere in your form where you are referencing any values inside your plot_repeats repeat group from outside it (which is what you should first look for if you ever get this error).
Again, I’ve been unable to reproduce this error with your above XLSForm definition.
Thank you so much for looking into this. It is interesting that you don’t get the problem, so I will certainly check that KoboCollect is updated to the version that you specify. I will then retry the form and see if I get the same error, and I will let you know.
Thank you very much again for your help with this, it is really appreciated!