jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Descendant-or-self
Date Mon, 13 Mar 2006 13:34:32 GMT
Hi Alvaro,

as per XPath specification [1] your query will be expanded to:

/descendant-or-self::node()/myTopNode/descendant-or-self::node()/*

which will effectively match only descendant nodes of /myTopNode

what you are probably looking for is:

//myTopNode/descendant-or-self::node()

but this is currently not supported by jackrabbit because it is not 
required by the JCR spec.

regards
  marcel

[1] http://www.w3.org/TR/xpath20/#abbrev

Alvaro Gonzalez wrote:
> Hi list,
> 
> I have been doing some tests with "//" (descendant-or-self) axis, and i 
> think is not interpreted correctly by Jacrabbit Query Builder.
> A query with this axis returns only "descendant" nodes instead of 
> "descendant-or-self" nodes. For example with this piece of code:
> 
>        Node myTopNode = 
> rootNode.addNode("myTopNode");                             
> myTopNode.addNode("subNode");              
> myTopNode.addNode("subNode");              rootNode.save();
>        String query = "//myTopNode//*";
>        //Should find all the 3 nodes: myTopNode and 2 subnodes.
>        QueryManager qm = currentSession.getWorkspace().getQueryManager();
>        Query q = qm.createQuery(query, Query.XPATH);
>        QueryResult qr =  q.execute();                             
> NodeIterator nodes = qr.getNodes();
>        assertEquals(3, nodes.getSize());
> 
> the test fails because it only finds two nodes instead of three. Is this 
> a bug? Am I misunderstanding "//" axis?
> 
> Regards,
> 
>  Alvaro
> 


Mime
View raw message