You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Roy Teeuwen <ro...@teeuwen.be> on 2016/10/07 15:42:44 UTC

XPath query

Hey all,

Seeing as I don’t seem to find a oak-users to subscribe to, I’m going to post the question here:

When doing the following XPath query in JCR 2, it would select me all the nodes that has a subnode named test. But since oak, this query does not work anymore. Is there a reason this stopped working or a way to make it work again

Some query example:
/jcr:root//*[test] or /jcr:root/content/site//element(*,nt:unstructured)[@jcr:createdBy='admin' and test]

Greetings,
Roy

Re: XPath query

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

Sorry typo in "type", wanted to write "typo":

>I thought even in Jackrabbit 2.x, the "test" was assumed to be a type and
>automatically converted to "@test"...

Should read:

I thought even in Jackrabbit 2.x, the "test" was assumed to be a typo ...


Regards,
Thomas


Re: XPath query

Posted by Roy Teeuwen <ro...@teeuwen.be>.
Hey Thomas,

I tested the query on a JCR 2.x ;) it used to worked there. I would use it in situations where the query goes deeper, something like /jcr:root/content/site//element(*,cq:PageContent)[parsys/some-component] to select pages with a specific component in the parsys
But yup! your adjustment seems to work, thanks a lot

Greetings,
Roy
> On 11 Oct 2016, at 12:03, Thomas Mueller <mu...@adobe.com> wrote:
> 
> Hi,
> 
> I thought even in Jackrabbit 2.x, the "test" was assumed to be a type and
> automatically converted to "@test"... Maybe I'm wrong.
> 
> What should work (for both Jackrabbit 2.x and Oak) is using
> "test/@jcr:primaryType" instead of "test". So:
> 
>    /jcr:root//*[test/@jcr:primaryType]
>    /jcr:root/content/site//element(*,nt:unstructured)
>        [@jcr:createdBy='admin' and test/@jcr:primaryType]
> 
> 
> Regards,
> Thomas
> 
> On 07/10/16 17:42, "Roy Teeuwen" <ro...@teeuwen.be> wrote:
> 
>> Hey all,
>> 
>> Seeing as I donąt seem to find a oak-users to subscribe to, Iąm going to
>> post the question here:
>> 
>> When doing the following XPath query in JCR 2, it would select me all the
>> nodes that has a subnode named test. But since oak, this query does not
>> work anymore. Is there a reason this stopped working or a way to make it
>> work again
>> 
>> Some query example:
>> /jcr:root//*[test] or
>> /jcr:root/content/site//element(*,nt:unstructured)[@jcr:createdBy='admin'
>> and test]
>> 
>> Greetings,
>> Roy
> 


Re: XPath query

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

I thought even in Jackrabbit 2.x, the "test" was assumed to be a type and
automatically converted to "@test"... Maybe I'm wrong.

What should work (for both Jackrabbit 2.x and Oak) is using
"test/@jcr:primaryType" instead of "test". So:

    /jcr:root//*[test/@jcr:primaryType]
    /jcr:root/content/site//element(*,nt:unstructured)
        [@jcr:createdBy='admin' and test/@jcr:primaryType]


Regards,
Thomas

On 07/10/16 17:42, "Roy Teeuwen" <ro...@teeuwen.be> wrote:

>Hey all,
>
>Seeing as I don¹t seem to find a oak-users to subscribe to, I¹m going to
>post the question here:
>
>When doing the following XPath query in JCR 2, it would select me all the
>nodes that has a subnode named test. But since oak, this query does not
>work anymore. Is there a reason this stopped working or a way to make it
>work again
>
>Some query example:
>/jcr:root//*[test] or
>/jcr:root/content/site//element(*,nt:unstructured)[@jcr:createdBy='admin'
>and test]
>
>Greetings,
>Roy