jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gadbury <gadb...@googlemail.com>
Subject Re: XPath query with path constraint and same name siblings
Date Wed, 17 Mar 2010 08:52:16 GMT

Hi Justin,

Thanks for your reply.  I wish to perform a query at a given ('provider')
node, to find all nodes of a certain type that are children of the provider. 
I had been using the provider node's path to provide the path constraint in
the query.  The problem was that the first provider node's path returns
../provider, rather than ../provider[1].

How do you mean by node graph?  Please would you be able to provide an
example...?  Do you mean call getNodes() on the providerNode?  If so, how
would I supply property or type constraints?

This is what I am currently doing:

	Node providerNode = jcrSession.getNodeByUUID(providerRepositoryUUID);
	String providerNodePath = providerNode.getPath();
	//Nasty same name siblings!  The first same name sibling i.e. provider
doesn't have the array index notation.  
	//Therefore, the path of the first provider is ../provider and not
../provider[1].  Without the array index notation, we get all providers!
	if (providerNode.getIndex() == 1)
		providerNodePath += "[1]";
	QueryManager queryManager = jcrSession.getWorkspace().getQueryManager();
	String queryString = "/jcr:root" + providerNodePath + "//element(*,
	Query query = queryManager.createQuery(queryString, Query.XPATH);
	QueryResult queryResult = query.execute();

Thanks and kind regards,


View this message in context: http://n4.nabble.com/XPath-query-with-path-constraint-and-same-name-siblings-tp1594661p1596054.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

View raw message