Hi All,
We found that QueryManager throws exception about path with digits. For instance the following query will trigger the exception:
/jcr:root/content/mysite/events/2024/special-events//element(*,cq:PageContent)[@sling:resourceType='mysite/pages/event-detail' ] order by @datestamps ascending
It will automatically append an "*" to 2024, making it as /jcr:root/content/mysite/events/2024(*)/special-events//element(*,cq:PageContent)[@sling:resourceType='mysite/pages/event-detail' ] order by @datestamps ascending.
So that it will throw an exception
Is there any solution getting rid of this?
Thanks!
-kt
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @kevingtan
It seems, first character is required to be non-digit, you can switcg to SQL/SQL2 or use Query Builder query
QueryBuilder Example example :
path=/content/mysite/events/2024/special-events
type=cq:PageContent
property=sling:resourceType
property.value=mysite/pages/event-detail
orderby=@datestamps
orderby.sort=desc
Hi @kevingtan
It seems, first character is required to be non-digit, you can switcg to SQL/SQL2 or use Query Builder query
QueryBuilder Example example :
path=/content/mysite/events/2024/special-events
type=cq:PageContent
property=sling:resourceType
property.value=mysite/pages/event-detail
orderby=@datestamps
orderby.sort=desc
Thanks for the suggestion. I will try that.
Hi @kevingtan ,
The issue you are experiencing with the XPath query and paths containing digits is due to the way XPath handles paths that start with a digit. According to the XPath specification, a path step that starts with a digit is not valid syntax.
To work around this issue, you can use the `fn:name()` function in your XPath query to match the nodes based on their name instead of the path. Here's an example of how you can modify your query:
```xpath
/jcr:root/content/mysite/events//*[fn:name() = '2024']/special-events//element(*,cq:PageContent)[@sling:resourceType='mysite/pages/event-detail'] order by @datestamps ascending
```
By using the `fn:name()` function, you can match the nodes with the name "2024" without encountering the syntax issue.
Alternatively, if you have control over the node structure, you can consider prefixing the node name with a letter or a non-digit character to avoid the XPath syntax limitation.
It's important to note that the solution provided assumes you are using XPath queries in AEM. If you are using JCR-SQL2 queries, you may need to adjust the syntax accordingly.
If the issue persists or if you have further questions, it is recommended to reach out to Adobe Support or your AEM implementation partner for further assistance.