Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 41926 invoked from network); 14 Aug 2007 21:12:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Aug 2007 21:12:38 -0000 Received: (qmail 28252 invoked by uid 500); 14 Aug 2007 21:12:35 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 28228 invoked by uid 500); 14 Aug 2007 21:12:35 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 28219 invoked by uid 99); 14 Aug 2007 21:12:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Aug 2007 14:12:35 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gcaju-users@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Aug 2007 21:12:44 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IL3gH-00052v-LB for users@jackrabbit.apache.org; Tue, 14 Aug 2007 23:12:01 +0200 Received: from gateway.subshell.com ([212.79.22.193]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Aug 2007 23:12:01 +0200 Received: from christoph by gateway.subshell.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Aug 2007 23:12:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: users@jackrabbit.apache.org From: Christoph Kiehl Subject: Re: query for child property Date: Tue, 14 Aug 2007 23:12:05 +0200 Lines: 77 Message-ID: References: <12130957.post@talk.nabble.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: gateway.subshell.com User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) In-Reply-To: <12130957.post@talk.nabble.com> Sender: news X-Virus-Checked: Checked by ClamAV on apache.org bilobag wrote: > I have the following node structure. I am having issues running an xpath > query that searches for a cwe:comment property and returns a cwe:file node. > I have read through the forum, but can't figure out if this functionality is > supported in version 1.3.1. > > nodetypes: > [cwe:file] > nt:hierarchyNode, mix:referenceable , mix:versionable > orderable > - cwe:filename (string) mandatory > - cwe:filesize (long) > + jcr:content (nt:resource) primary mandatory > + * (cwe:comment) = cwe:comment ignore multiple > > > [cwe:comment] > nt:hierarchyNode, mix:referenceable > - cwe:body (string) mandatory > - cwe:createdUser (string) mandatory > - cwe:createdDate (date) mandatory > > query 1: > //element(*,cwe:file)[jcr:contains(jcr:content/@jcr:mimeType, > 'application/msword')]/rep:excerpt() order by @jcr:score desc > > query 2: > //element(*,cwe:file)[jcr:contains(cwe:comment/@cwe:body, > 'banana')]/rep:excerpt() order by @jcr:score desc I used the following code to reproduce your case using the given CND (I only omitted the "jcr:content" child node of "cwe:file"): public class Test { public static void main(String[] args) throws Exception { TransientRepository repository = new TransientRepository(); Session session = repository.login(new SimpleCredentials("a", "b".toCharArray())); try { NodeTypeManagerImpl ntm = ((NodeTypeManagerImpl) session.getWorkspace().getNodeTypeManager()); ntm.registerNodeTypes( Test.class.getResourceAsStream("nodetypes.cnd"), JackrabbitNodeTypeManager.TEXT_X_JCR_CND, true); Node rootNode = session.getRootNode(); if (rootNode.hasNode("test")) { rootNode.getNode("test").remove(); } Node fileNode = rootNode.addNode("test", "cwe:file"); fileNode.setProperty("cwe:filename", "filename"); Node commentNode = fileNode.addNode("cwe:comment"); commentNode.setProperty("cwe:body", "banana"); commentNode.setProperty("cwe:createdUser", "banana"); commentNode.setProperty("cwe:createdDate", Calendar.getInstance()); session.save(); QueryManager queryManager = session.getWorkspace().getQueryManager(); Query query = queryManager.createQuery( "//element(*,cwe:file)[jcr:contains(cwe:comment/@cwe:body,'banana')]/rep:exerpt() order by @jcr:score desc", Query.XPATH); QueryResult result = query.execute(); System.out.println(result.getNodes().getSize()); } finally { session.logout(); } } } This outputs the expected result of "1". Are you sure your child nodes name is "cwe:comment"? In your CND the name of the _node type_ is "cwe:comment" but this doesn't necessarily mean that the child nodes name is "cwe:comment" as well. Could you may be show us the code where you create the nodes? Cheers, Christoph