Difference between revisions of "XPath queries"

From OpenKM Documentation
Jump to: navigation, search
Line 21: Line 21:
  
 
  //element(*,okm:document)[jcr:contains(okm:content,'linux') and jcr:contains(@okm:keywords,'ubuntu')]
 
  //element(*,okm:document)[jcr:contains(okm:content,'linux') and jcr:contains(@okm:keywords,'ubuntu')]
 +
  
 
== type restrictions ==  
 
== type restrictions ==  
 
We can specify the type of node that query returns. Restrictions include inheritage all subtype are included as possible results. The function element is used to evaluate a node type.
 
We can specify the type of node that query returns. Restrictions include inheritage all subtype are included as possible results. The function element is used to evaluate a node type.
  
'''example all the node folders'''
+
 
 +
'''for example the node folders'''
  
 
  //element(*, okm:folder)
 
  //element(*, okm:folder)
  
  
 +
== Property restrictions ==
 +
A query can have property restrictions. The operators used are (=, !=, <, <=, >, >=) in addtion there's some extra operators like jcr:like() and jcr:contains().
 +
 +
'''getting folders with author pavila'''
 +
 +
//element(*, okm:folder)[@okm:author = 'pavila']
 +
 +
'''documents name starting with linux'''
 +
 +
//element(*, okm:document)[jcr:like(@okm:name, 'linux%')]
 +
 +
'''documents with indexed content jackrabbit'''
 +
 +
//element(*, okm:resource)[jcr:contains(., 'jackrabbit')]/@jcr:path
 +
 +
 +
== Order ==
 +
At ends query can be indicated the order of results.
 +
 +
'''ordering by name'''
 +
 +
  //element(*, okm:document)[@okm:keywords != ''] order by @okm:name
 +
 +
Normally is used jcr:score to ordering, that indicates de ranking of the results.
  
  
 
[[Category: Administration Guide]]
 
[[Category: Administration Guide]]
 
[[Category: OKM Network]]
 
[[Category: OKM Network]]

Revision as of 11:19, 3 March 2010

Can be found more information about XPATH in http://www.w3.org/TR/xpath20/

Examples

locked documents

//element(*, okm:document)[@jcr:lockOwner]

locked documents by user pavila

//element(*, okm:document)[@okm:author='pavila']

search documents by content

//element(*, okm:document)[jcr:contains(okm:content, 'linux')]

folders created by user pavila

//element(*, okm:folder)[@okm:author='pavila']

example of complex query, documents with content linux and keyword ubuntu

//element(*,okm:document)[jcr:contains(okm:content,'linux') and jcr:contains(@okm:keywords,'ubuntu')]


type restrictions

We can specify the type of node that query returns. Restrictions include inheritage all subtype are included as possible results. The function element is used to evaluate a node type.


for example the node folders

//element(*, okm:folder)


Property restrictions

A query can have property restrictions. The operators used are (=, !=, <, <=, >, >=) in addtion there's some extra operators like jcr:like() and jcr:contains().

getting folders with author pavila

//element(*, okm:folder)[@okm:author = 'pavila']

documents name starting with linux

//element(*, okm:document)[jcr:like(@okm:name, 'linux%')]

documents with indexed content jackrabbit

//element(*, okm:resource)[jcr:contains(., 'jackrabbit')]/@jcr:path


Order

At ends query can be indicated the order of results.

ordering by name

 //element(*, okm:document)[@okm:keywords != ] order by @okm:name

Normally is used jcr:score to ordering, that indicates de ranking of the results.