jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Wehrens <wehr...@aei.mpg.de>
Subject Re: Xpath question
Date Tue, 11 Apr 2006 11:04:10 GMT
Hi,

I just checked it with the latest svn version and it still does not work how
I think it should. I will submit a bug report.


On 10.04.2006 10:52 Uhr, "Marcel Reutegger" <marcel.reutegger@gmx.net>
wrote:

> 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:
> 
> /jcr:root/*/wiki:entry[5]
> 
>> 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?
> 

Jupp, make it ascending it the query above ;)

Thanks, Oliver

> regards
>   marcel
> 

-- 
Oliver Wehrens
+49 170 785 1323
http://wehrens.net/oliver







Mime
View raw message