Hi Roy

Like others said before, ISO9075 is what you need. You only need to
encode the first digit. The encoding is simple enough to remember (if
used regularly ;) ):

0: _x0030_
1: _x0031_
2: _x0032_
...

Your query would thus become:
/jcr:root/content/launches/_x0032_019/_x0030_8/_x0032_9/my-launch/content/site-name//*[@sling:resourceType='some/components/path']

As a shortcut in situations where the depth is known I sometimes use:
/jcr:root/content/launches/*/*/*/my-launch/content/site-name//*[@sling:resourceType='some/components/path']

Another alternative would be:
/jcr:root/content/launches/*[fn:name() = '2019']/*[fn:name() =
'08']/*[fn:name() =
'29']/my-launch/content/site-name//*[@sling:resourceType='some/components/path']

I believe that the ISO9075 encoded version performs best, but I didn't
verify that claim. Most likely performance is not your main concern in
any case, as all of the above should be reasonable fast  ;)

Regards
Julian

On Thu, Aug 29, 2019 at 6:52 PM Eric Norman <eric.d.nor...@gmail.com> wrote:
>
> If I recall correctly, if you want to use paths in XPath queries then you
> need to escape the path segments according to ISO9075 rules.   For your
> referenced, there is a brief section about that on the wiki at [1].
>
> Also, there is a utility class in jackrabbit that can do the ISO9075 path
> encoding for you at [2] that you may utilize.
>
> 1.
> http://jackrabbit.apache.org/archive/wiki/JCR/EncodingAndEscaping_115513396.html
> 2.
> http://jackrabbit.apache.org/api/trunk/org/apache/jackrabbit/util/ISO9075.html
>
> I hope that helps.
>
> On Thu, Aug 29, 2019 at 8:54 AM Roy Teeuwen <r...@teeuwen.be> wrote:
>
> > Hey all,
> >
> > In the framework that we use (AEM) there is a folder structure as
> > following:
> >
> > /content/launches/2019/08/29/my-launch/content/site-name
> >
> > I would like to do a query to search for subresources in this site, but it
> > seems that this gives issues because an xpath query cannot take numbers as
> > path names:
> >
> > /jcr:root/content/launches/2019(*)/08/29/my-launch/content/site-name//*[@sling:resourceType='some/components/path'];
> > expected: jcr:root, /, *, @, (, .
> >
> > Is there any way around this to still make it work with xpath queries? Can
> > I escape it in any way? Or can I say "start the query below
> > /content/launches/2019/08/29/my-launch/content/site-name so that it doesnt
> > see the numbers in the query
> >
> > Thanks!
> > Roy
> >
> >

Reply via email to