Advanced Selectors with Apache Sling | Community
Skip to main content
October 16, 2015
Solved

Advanced Selectors with Apache Sling

  • October 16, 2015
  • 3 replies
  • 1200 views

Does Apache Sling provide functionality for more complex selectors? I need to be able to select nodes with certain child properties as well as get the first child of a given node. I was hoping there would be some ability to query based on the XPath, but this doesn't seem possible using the REST framework.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ogill

Don't see how you can do this without custom code. 

How about registering a servlet to act on a specific selector and then you can place the logic you want in there? 

[0] https://helpx.adobe.com/experience-manager/using/resourcetypes.html

[1] https://balawcm.wordpress.com/2012/11/14/develop-a-custom-cq-selector/

3 replies

Adobe Employee
October 16, 2015

A few questions if you don't mind:

What is it you are trying to achieve?

How do you you want to use this functionality?

Do you want to apply these selectors against all content or specific resource types?

October 16, 2015

I'm trying to select the first-of-type given a content path. I'm hoping I can use a selector like this *without* creating a whole new custom component. I am attempting to apply the selector against an image type, but if I can do it for any content, that would work as well.

ogillAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Don't see how you can do this without custom code. 

How about registering a servlet to act on a specific selector and then you can place the logic you want in there? 

[0] https://helpx.adobe.com/experience-manager/using/resourcetypes.html

[1] https://balawcm.wordpress.com/2012/11/14/develop-a-custom-cq-selector/