versioning (lastest version of documents)

When I do a query on the database I get all the versions of all documents that fullfill the query.
Is there a way to obtain (XQuery X-Query) only the latest versions of all the found documents?

In other words: Does Tamino keep track of a version number that is accessable to the user?
Or is the ‘last modified date’ what we need to use to get rid of older versions?

B.t.w. we are using a Java Servlet in which we implement the query functions.

any hint would be appreciated.

We found out that currently there is no way of retrieving only the latest versions of documents from a query.
The APIs that can help to do this (Slide 1.016, JSR147, JSR170) are currently not sufficiently devellopped to perform these tasks. When these APIs are devellopped futher (Slide 2.0 comes end of january) then ther may be more possible from the Java servlet. Doing these things from JScript then still needs a Java servlet as mediator to support the query.