You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by nch <un...@yahoo.com> on 2009/11/12 17:38:33 UTC

xpath

Hi, there.

I'm new to Jackrabbit and I'm having some problems to understand how xpath works here.
If I have the following hierarchy:
/test (jcr:folder)
+ file1.txt (jcr:file)
+ file2.txt (jcr:file)

then I can retrieve all nodes in /test by means of the following xpath expression "/jcr:root/test/*"

But, if I have the following:
/test (jcr:directory)

+ file1.txt

+ file2.txt

+ newfolder (jcr:folder)

then, the previous xpath expression does not yield any nodes.
Any explanations for this?

Kind regards.



      

Re: xpath

Posted by Rakesh Vidyadharan <ra...@sptci.com>.
On 12 Nov 2009, at 10:38:33 AM, nch wrote:

> Hi, there.
> 
> I'm new to Jackrabbit and I'm having some problems to understand how xpath works here.
> If I have the following hierarchy:
> /test (jcr:folder)
> + file1.txt (jcr:file)
> + file2.txt (jcr:file)
> 
> then I can retrieve all nodes in /test by means of the following xpath expression "/jcr:root/test/*"
> 
> But, if I have the following:
> /test (jcr:directory)
> 
> + file1.txt
> 
> + file2.txt
> 
> + newfolder (jcr:folder)
> 
> then, the previous xpath expression does not yield any nodes.
> Any explanations for this?

I forget if the default type for a query is nt:base or nt:unstructured.  If it is nt:unstructured, it will explain the issue with not finding the folder node.

Rakesh

Re: xpath

Posted by nch <un...@yahoo.com>.
  Sorry, I meant nt:file and nt:folder.
  I found I was swallowing an exception.

  Thanks!

--- El jue, 12/11/09, Alexander Klimetschek <ak...@day.com> escribió:

De: Alexander Klimetschek <ak...@day.com>
Asunto: Re: xpath
Para: users@jackrabbit.apache.org
Fecha: jueves, 12 de noviembre, 2009 19:25

On Thu, Nov 12, 2009 at 17:38, nch <un...@yahoo.com> wrote:
> I'm new to Jackrabbit and I'm having some problems to understand how xpath works here.
> If I have the following hierarchy:
> /test (jcr:folder)
> + file1.txt (jcr:file)
> + file2.txt (jcr:file)
>
> then I can retrieve all nodes in /test by means of the following xpath expression "/jcr:root/test/*"
>
> But, if I have the following:
> /test (jcr:directory)
>
> + file1.txt
>
> + file2.txt
>
> + newfolder (jcr:folder)
>
> then, the previous xpath expression does not yield any nodes.
> Any explanations for this?

It should be the same. Was there any error?

BTW: What are "jcr:directory", "jcr:file" and "jcr:folder" - custom
nodetypes? I suggest to use the standard nt:folder and nt:file.

BTW2: If you simply want to list child nodes at a given path, as your
xpath query does, I suggest to use JCR API navigation, rather then the
search. It will be simpler and faster. But of course this depends on
your application.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com



      

Re: xpath

Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Nov 12, 2009 at 17:38, nch <un...@yahoo.com> wrote:
> I'm new to Jackrabbit and I'm having some problems to understand how xpath works here.
> If I have the following hierarchy:
> /test (jcr:folder)
> + file1.txt (jcr:file)
> + file2.txt (jcr:file)
>
> then I can retrieve all nodes in /test by means of the following xpath expression "/jcr:root/test/*"
>
> But, if I have the following:
> /test (jcr:directory)
>
> + file1.txt
>
> + file2.txt
>
> + newfolder (jcr:folder)
>
> then, the previous xpath expression does not yield any nodes.
> Any explanations for this?

It should be the same. Was there any error?

BTW: What are "jcr:directory", "jcr:file" and "jcr:folder" - custom
nodetypes? I suggest to use the standard nt:folder and nt:file.

BTW2: If you simply want to list child nodes at a given path, as your
xpath query does, I suggest to use JCR API navigation, rather then the
search. It will be simpler and faster. But of course this depends on
your application.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com