Recently while verifying some of the components in Experience Editor, I observed that while adding a data source to the renderings, it was throwing an “End of string expected at position 22” error.
I checked the 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 the log file, and there was an error there, please see the above screenshot of what error it was.
It turns out Sitecore doesn’t like hyphens “-” in query path, and a few others which include:
- If your query contains the keyword “and“
- If the query contains the keyword “or“
- If the query contains the hyphen “–“
In my case when I checked the query and it contains the keyword “and“, which was basically failing and not allowing me to add data sources from the Experience editor.
Solution:
In order to fix this issue we can add escape character “#” before and after the items that contain 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 the Sitecore support team, and they have registered this as Wish/Feature, so, we may see this issue resolved in further coming product versions.
I hope this helps somebody.
Happy learning
Comments
Post a Comment