You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Akil Ali <Ak...@cognizant.com> on 2009/02/26 16:32:35 UTC

How to retrieve a node from a hierarchy?

I have a node hierarcy

A/B/C/D/1

i have to retrieve nodes under D i.e. 1

i have the information that it is under node D. But how to get the NODE
object of node D. from session. one way is if i have UUID then i can get the
NODE object and other way is to use XPATH. but i dont want to use both the
approach. Is there any other way to get the NODE object.?

Please reply

Akil
-- 
View this message in context: http://www.nabble.com/How-to-retrieve-a-node-from-a-hierarchy--tp22226591p22226591.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: How to retrieve a node from a hierarchy?

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Feb 26, 2009 at 4:57 PM, Akil Ali <Ak...@cognizant.com> wrote:
> Sorry to say, i dont want to use neither XPATH nor UUID.

Is there a reason why you don't want to use these mechanisms?

BR,

Jukka Zitting

Re: How to retrieve a node from a hierarchy?

Posted by Julian Reschke <ju...@gmx.de>.
Akil Ali wrote:
> 
> Sorry to say, i dont want to use neither XPATH nor UUID. so what would be
> the other solution to get the node.

So you want to access a node, but do not know its UUID, nor it's path.

There *is* no other way than to search for it, be it by a JCRF query, or 
by traversing the whole tree.

BR, Julian

RE: How to retrieve a node from a hierarchy?

Posted by Jou Kou-Rong <Ko...@irs.gov>.
Sorry. Accidental send my previous response.

Use node walking, starting from rootNode (session.getRootNode()).
Or if you have defined your node structure with a certain pattern, then
you can follow the pattern to reach your node quickly. For example, you
map a file in a local file system to a JCR repository node with a
pattern:
File system side: folder1/filder2/file1
JCR Node side: get appRootNode of your application, then folder1Node =
appRootNode.getNode("folder1");
 folder2Node = folder1Node.getNode("folder2");
 file1Node = folder2Node.getNode("file1");

Or 

file1Node = appRootNode.getNode("folder1/folder2/file1"); -- like Alex
suggestion

Usually you have an index that persist somewhere (database or file
system) to refer to your JCR node, so you can do this kind of quick
mapping.




-----Original Message-----
From: Akil Ali [mailto:Akil.Ajani@cognizant.com] 
Sent: Thursday, February 26, 2009 10:57 AM
To: users@jackrabbit.apache.org
Subject: Re: How to retrieve a node from a hierarchy?



Sorry to say, i dont want to use neither XPATH nor UUID. so what would
be the other solution to get the node.

Akil


Alexander Klimetschek wrote:
> 
> On Thu, Feb 26, 2009 at 4:42 PM, Akil Ali <Ak...@cognizant.com>
> wrote:
>> Sorry sir i dont have the information that NODE D is under A/B/C. so 
>> how to get the NODE object of NODE D. without prior knowledge that D 
>> is under A/B/C.
> 
> Well, you could either navigate to it by looking for whatever marks 
> that node as "D" (properties, node type, node name) or do the same 
> with an xpath query. Typically it has a node type, let's say 
> "my:dtype", so the query would be:
> 
> //element(*, my:dtype)
> 
> This gives you all nodes of type "my:dtype". If you have some 
> additional property you want to check for, you can do this:
> 
> //element(*, my:dtype)[@myprop='foobar']
> 
> which gives you all my:dtype nodes with a property set to the value 
> "foobar".
> 
> Regards,
> Alex
> 
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

--
View this message in context:
http://www.nabble.com/How-to-retrieve-a-node-from-a-hierarchy--tp2222659
1p22227106.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


RE: How to retrieve a node from a hierarchy?

Posted by Jou Kou-Rong <Ko...@irs.gov>.
Use node walking, starting from rootNode (session.getRootNode()).
Or if you have defined your node structure with a certain pattern, then
you can follow the pattern to reach your node quickly. For example, you
map a file in a local file system to a JCR repository node with a
pattern:
File system side: folder1/filder2/file1
JCR Node side: get appRootNode of your application, 
then
folder1Node = appRootNode.getNode("folder1");




-----Original Message-----
From: Akil Ali [mailto:Akil.Ajani@cognizant.com] 
Sent: Thursday, February 26, 2009 10:57 AM
To: users@jackrabbit.apache.org
Subject: Re: How to retrieve a node from a hierarchy?



Sorry to say, i dont want to use neither XPATH nor UUID. so what would
be the other solution to get the node.

Akil


Alexander Klimetschek wrote:
> 
> On Thu, Feb 26, 2009 at 4:42 PM, Akil Ali <Ak...@cognizant.com>
> wrote:
>> Sorry sir i dont have the information that NODE D is under A/B/C. so 
>> how to get the NODE object of NODE D. without prior knowledge that D 
>> is under A/B/C.
> 
> Well, you could either navigate to it by looking for whatever marks 
> that node as "D" (properties, node type, node name) or do the same 
> with an xpath query. Typically it has a node type, let's say 
> "my:dtype", so the query would be:
> 
> //element(*, my:dtype)
> 
> This gives you all nodes of type "my:dtype". If you have some 
> additional property you want to check for, you can do this:
> 
> //element(*, my:dtype)[@myprop='foobar']
> 
> which gives you all my:dtype nodes with a property set to the value 
> "foobar".
> 
> Regards,
> Alex
> 
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

--
View this message in context:
http://www.nabble.com/How-to-retrieve-a-node-from-a-hierarchy--tp2222659
1p22227106.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: How to retrieve a node from a hierarchy?

Posted by Akil Ali <Ak...@cognizant.com>.

Sorry to say, i dont want to use neither XPATH nor UUID. so what would be
the other solution to get the node.

Akil


Alexander Klimetschek wrote:
> 
> On Thu, Feb 26, 2009 at 4:42 PM, Akil Ali <Ak...@cognizant.com>
> wrote:
>> Sorry sir i dont have the information that NODE D is under A/B/C. so how
>> to
>> get the NODE object of NODE D. without prior knowledge that D is under
>> A/B/C.
> 
> Well, you could either navigate to it by looking for whatever marks
> that node as "D" (properties, node type, node name) or do the same
> with an xpath query. Typically it has a node type, let's say
> "my:dtype", so the query would be:
> 
> //element(*, my:dtype)
> 
> This gives you all nodes of type "my:dtype". If you have some
> additional property you want to check for, you can do this:
> 
> //element(*, my:dtype)[@myprop='foobar']
> 
> which gives you all my:dtype nodes with a property set to the value
> "foobar".
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-retrieve-a-node-from-a-hierarchy--tp22226591p22227106.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: How to retrieve a node from a hierarchy?

Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Feb 26, 2009 at 4:42 PM, Akil Ali <Ak...@cognizant.com> wrote:
> Sorry sir i dont have the information that NODE D is under A/B/C. so how to
> get the NODE object of NODE D. without prior knowledge that D is under
> A/B/C.

Well, you could either navigate to it by looking for whatever marks
that node as "D" (properties, node type, node name) or do the same
with an xpath query. Typically it has a node type, let's say
"my:dtype", so the query would be:

//element(*, my:dtype)

This gives you all nodes of type "my:dtype". If you have some
additional property you want to check for, you can do this:

//element(*, my:dtype)[@myprop='foobar']

which gives you all my:dtype nodes with a property set to the value "foobar".

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: How to retrieve a node from a hierarchy?

Posted by Akil Ali <Ak...@cognizant.com>.

Sorry sir i dont have the information that NODE D is under A/B/C. so how to
get the NODE object of NODE D. without prior knowledge that D is under
A/B/C.


Jukka Zitting wrote:
> 
> Hi,
> 
> On Thu, Feb 26, 2009 at 4:32 PM, Akil Ali <Ak...@cognizant.com>
> wrote:
>> I have a node hierarcy
>>
>> A/B/C/D/1
>>
>> i have to retrieve nodes under D i.e. 1
>>
>> i have the information that it is under node D. But how to get the NODE
>> object of node D. from session. one way is if i have UUID then i can get
>> the
>> NODE object and other way is to use XPATH. but i dont want to use both
>> the
>> approach. Is there any other way to get the NODE object.?
> 
> Try session.getRootNode().getNode("A/B/C/D")
> 
> BR,
> 
> Jukka Zitting
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-retrieve-a-node-from-a-hierarchy--tp22226591p22226806.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: How to retrieve a node from a hierarchy?

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Feb 26, 2009 at 4:32 PM, Akil Ali <Ak...@cognizant.com> wrote:
> I have a node hierarcy
>
> A/B/C/D/1
>
> i have to retrieve nodes under D i.e. 1
>
> i have the information that it is under node D. But how to get the NODE
> object of node D. from session. one way is if i have UUID then i can get the
> NODE object and other way is to use XPATH. but i dont want to use both the
> approach. Is there any other way to get the NODE object.?

Try session.getRootNode().getNode("A/B/C/D")

BR,

Jukka Zitting