On Tue, Jan 6, 2009 at 7:11 AM, yanshaozhiGmail <[email protected]> wrote:
> HI:
> Is there any method can select specified properties I want,
>
> "//element(*,rep:Group )//(@rep:principalName|@jcr:score) "
>
> as the statement up , I only want to query the properties rep:principalName
> and jcr:score,
>
> however it doesn't work ,why?
>
> How can I realize it?
A JCR query will always return nodes (also accessible as "rows"). See
the QueryResult.getNodes() and QueryResult.getRows() method.
Your query could look like this; it will return all nodes that have a
rep:principalName property with a value:
//element(*,rep:Group )//*...@rep:principalName]
(BTW, @jcr:score is not a standard property, it is used for ordering,
so you could append " order by @jcr:score" to the query above).
Now you would retrieve the property through the QueryResult, for example:
NodeIterator nodes = queryResult.getNodes();
while (nodes.hasNext()) {
String name = nodes.nextNode().getProperty("rep:principalName").getString();
}
Hope that helps,
Alex
--
Alexander Klimetschek
[email protected]