You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Michael Korat <mi...@hms.org> on 2007/08/21 15:47:20 UTC
Multiple jcr:deref in query
Hi all,
I have to do a query to retrieve all Nodes from the 'Site'
subtree of my repository that contains certain content.The problem
is that the actual content is stored in other nodes, and I only
hold references to them. Here's a little little overview of the
structure of my repository:
Root
|
|+Content
| |+DataNodeA
| | |@Content
| |+DataNodeB
| | |@Content
| |
| |+DocumentNodeA
| |+LinkToDataNodeA > my:DataLink
| | |@RefToData = DataNodeA
| |+LinkToDataNodeB
| |@RefToData = DataNodeB
|
|+Site
|+PageA
|+LinkToDocumentNodeA > my:LinkToDoc
|@RefToDoc = DocumentNodeA
The node i want to retrieve in this case is PageA. PageA
holds a subnode of the type my:LinkToDoc which contains
the reference to a DocumentNode. This DocumentNode has
subnodes which have references to DataNodes, which contain
the actual content.
I wrote a query that should return all the nodes that are somehow
referenced by PageA, and contain the wanted value:
/jcr:root/Content//element(*, my:LinkToDoc)/jcr:deref(@RefToDoc, '*')
//element(*, my:DataLink)/jcr:deref(@RefToData,
'*')[jcr:contains(.,'some value')]
Unfortunately, the result of this is always zero. If I execute the
query without the jcr:contains constraint at the end I get the expected
set of DataNodes back:
/jcr:root/Content//element(*, my:LinkToDoc)/jcr:deref(@RefToDoc, '*')
//element(*, my:DataLink)/jcr:deref(@RefToData, '*')
My question is if there is a limitation to the use of multiple jcr:deref
in a single query, or mixing jcr:deref with constraints or if there
is another convenient (and fast) way to do such a query?
Regards,
Michael
Re: Multiple jcr:deref in query
Posted by Marcel Reutegger <ma...@gmx.net>.
Michael Korat wrote:
> I wrote a query that should return all the nodes that are somehow
> referenced by PageA, and contain the wanted value:
>
> /jcr:root/Content//element(*, my:LinkToDoc)/jcr:deref(@RefToDoc, '*')
> //element(*, my:DataLink)/jcr:deref(@RefToData,
> '*')[jcr:contains(.,'some value')]
>
> Unfortunately, the result of this is always zero. If I execute the
> query without the jcr:contains constraint at the end I get the expected
> set of DataNodes back:
>
> /jcr:root/Content//element(*, my:LinkToDoc)/jcr:deref(@RefToDoc, '*')
> //element(*, my:DataLink)/jcr:deref(@RefToData, '*')
does //*[jcr:contains(.,'some value')] return any result?
> My question is if there is a limitation to the use of multiple jcr:deref
> in a single query, or mixing jcr:deref with constraints or if there
> is another convenient (and fast) way to do such a query?
no, there's not limit. you can use as many jcr:derefs as you like.
as an alternative you can also search for the data nodes directly and then do
the dereferencing manually using the API (Node.getReferences()).
regards
marcel