jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Rhodes <spamsu...@rhoderunner.com>
Subject Re: // in xpath does not match immediate children
Date Thu, 03 May 2007 01:30:24 GMT
Ruchi,
You were correct!  If I remove the space in my path, it works.

I wrote this method that cleans up my path so that it can be used in an xpath expression:
 It works.

	private String escapePath(String contentPath) {
		String[] nodes = contentPath.split("/");
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < nodes.length; i++) {
			if (sb.length() > 0) {
				sb.append("/");
			}
			String escapedName = ISO9075.encode(nodes[i]);
			sb.append(escapedName);

		}
		return sb.toString();
		
	}

Thanks for the answer.
Phillip


----- Original Message -----
From: "ruchi goel" <Ruchi.Goel@Sun.COM>
To: users@jackrabbit.apache.org
Sent: Wednesday, May 2, 2007 3:20:38 AM (GMT-0500) America/New_York
Subject: Re: // in xpath does not match immediate children

Hi Philips ,
   I am doing the same but it works.
Say , eg. I want all documents under /cms/childfolder1 which have author 
as "sushma", any of the following queries returns me the documents which 
are authored by 'sushma'

    *  /jcr:root/cms/childfolder1//*[@ps:author='sushma'] 
    * /jcr:root/cms/childfolder1/element(*,ps:document)[@ps:author='sushma']


Is the space between your search string 'tag' + space + '1' a problem ?

Did you try testing it via eclipse Jackrabbit Viewer plugin ?


-Ruchi

Phillip Rhodes wrote:
> Hello everyone,
>
> I am using jackrabbit to store "tags" that a user creates. 
> Given a structure (below) where each leaf node has an attribute of CONTENT_TYPE with
a value of "Tag"
> /myfolder/tag 1/Tag 1
> /myfolder/tag 2/Tag 2
> /myfolder/tag 3/Tag 3
>
> My application needs to be able to query for what tags exist under a node path 
> e.g. 
> what tags are under /myfolder/tag 1?
> what tags are usder /myfolder/?
>
> My problem is that my xpath expression is not working for queries that pass the tag parent
in as a node to look down.
> I have a tag with a node path of /myfolder/tag 1/Tag 1 , but xpath search for tags in
/myfolder/tag 1 fails to find any nodes.
>
> This query will not find it:
> /jcr:root/myfolder/tag 1//*[@CONTENT_TYPE = 'Tag']
>
> This query does find it (but it is not restrictive enough, returns nodes in all folders).
> /jcr:root/myfolder//*[@CONTENT_TYPE = 'Tag']
> Results
> /myfolder/tag 1/Tag 1
> /myfolder/tag 2/Tag 2
>   

> /myfolder/tag 3/Tag 3
> /myfolder/tag 4/Tag 4
>
>
> Is there a way to do a search in xpath that does children AND it's descendents?
>
> Thanks!
>
>
>   



Mime
View raw message