jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Xpath question
Date Mon, 10 Apr 2006 08:52:57 GMT
Hi Oliver,

Oliver Wehrens wrote:
> I have some trouble with xpath queries to jackrabbit.
> I want to select the 5th entry and my query would look something like:
> q = qm.createQuery("//wiki:entry[5]", Query.XPATH);
> qr = q.execute();
> NodeIterator it = qr.getNodes();
> while (it.hasNext()) {
>    Node n = it.nextNode();
> System.out.println("n.getProperty("wiki:content").getValue().getString());
> }
> But if I get back the NodeIterator it contains all nodes...where does it go
> wrong ?

this is a bug in the query builder. could you please create a jira
issue? Thanks.

the problem is with the descendant-or-self axis. if you just use the
child node axis queries with position predicates work. e.g. something
like this:


> Variations with //wiki:entry[position()=last()] or things like that also
> always give me back the whole list ?

same bug as above.

> What I try to achieve at the end is to get back the sorted ten last entries
> by time (so a order by a property and position()<10, e.g.
> //wiki:entry[position()<10] order by @wiki:date descending).

this is actually not yet supported in jackrabbit. so far you can only
use position predicates with the equals operator.

I'm not sure I understand your use case. If it were possible to execute 
the previous query in jackrabbit you would get the *first* ten 
wiki:entry nodes (in document order) and then sorted by date. I guess 
what you rather want are the 10 latest wiki entries, right?


View raw message