Recently while verifying some of the components in Experience Editor, I observed that while adding datasource to the renderings, it was throwing “End of string expected at position 75” error.
I checked following things to troubleshoot the issue:
- If Datasource location specified in the rendering exists or not, and it exists.
- If Datasource template is defined in rendering or not, and it was there.
- Check the errors in log file, and there was an error there, please see the below screen shot what error it was.
- Following error was visible in front end while adding datasource.
It turns out Sitecore doesn’t like hyphens “-” in query path, and few other which includes:
- If you query contains keyword “and“
- If query contains keyword “or“
- If query contains hyphen “–“
In my case when i checked the query and it contains keyword “and“, which was basically failing and not allowing me to add datasource from Experience editor.
In order to fix this issue we can add escape character “#” before and after of the items that contains any of these keywords or hyphen “-“, so, for example:
Before : query:./ancestor::*[@@templatename=’SitecoreRoot’]/Global//Modules/Image and Media Module
After : query:./ancestor::*[@@templatename=’SitecoreRoot’]/Global//Modules/#Image and Media Module#
After making this change, the issue was fixed.
It seems this issue was there in Sitecore 6, but it can be replicated in Sitecore 8.1 (rev 160302) as well.
I have raised this with Sitecore support team, and they have registered this as Wish/Feature, so, we may see this issue resolved in coming product versions.
I hope this helps somebody.
Happy learning 🙂