- The XPath Query that will be used for searching can be in any of the given following format. The queries should be preceded by either '/' or '//' according to the search format. And rest of the expressions should be separated by forward slashes '/'.
- //<HUMAN_READABLE_NAME>[<SEARCH CRITERIA>]
- //<HUMAN_READABLE_NAME>/<ASSOCIATION_NAME OR CHILD RESOURCE OR COLLECTION NAME>
- //<HUMAN_READABLE_NAME>[<SEARCH CRITERIA>]/<ASSOCIATION_NAME OR CHILD RESOURCE OR COLLECTION NAME>
- //<HUMAN_READABLE_NAME>[<SEARCH CRITERIA>]/<ASSOCIATION_NAME OR CHILD RESOURCE OR COLLECTION NAME>[<SEARCH CRITERIA>]
The XPath query search can be done by giving the registry path of a resource. The format /<ANY_RESOURCE_OR_COLLECTION_NAME>/... would return all the immediate child resources and collections of the selected resource or collection. The following query would give all the immediate child collections of _system.
E.g. - /_system
A specific resource or collection under the root can be searched by just defining the name after '//' according to the format //<ANY_RESOURCE_OR_COLLECTION_NAME>/... (this may not work with root) . The query to search a resource called foo should be as given below.
E.g. - //foo
- The XPath search can be performed by being specific to a particular media type. The media type should be define in the query by a human readable name. Therefor prior executing such query the perticular human readable media type should be defined inside the
$GREG_HOME/repository/conf/etc/mime.mappings. The way to exactly define a human readable media type is given in the page Configuration Files.
If it is needed to search and list out all the resources of a particular media type then according to the format //<HUMAN_READABLE_NAME> you can define only the human readable name of the media type after '//'. If service is the corresponding human readable name for service media type then all the services available in the registry would be resulted by providing the following query.
E.g. - //service
- For more enhanced searching a search criteria can be defined along with the human readable name as given in the format //<HUMAN_READABLE_NAME>[<SEARCH CRITERIA>] . A search criteria can be made using following information of a resource.
The given above information should be defined along with its values in the search criteria inside square brackets after the human readable name. In order to search services made by user admin the following query can be used.
E.g. - //service[@author='admin']
- The facility of using operators is also available with XPath Query search. A user can have "and" and "or" in between predicates. Similarly you can have "=" and "!=" only for the information that accept negation ( author, updator, mediaType, created, updated ). You can also do <, >, <=, >=, for property values.
If a service contains properties called "foo" and "bar" a search criteria can be defined to look up for services which has both the properties as given below.
E.g. - //service[@propertyName='foo' and @propertyValue='bar']
And only for one of the properties as given below.
E.g. - //service[@propertyName='foo' or @propertyValue='bar']
A range of values can also be defined for scenarios like search by the properties of a resource. In order to retrieve services which has the property "foo" with value less than or equal to 10 the query should be as follows.
E.g. - //service[@foo <= 10]
In scenarios like search a resource by tags, it may be necessary to define multiple values given as tags to do a search. Multiple values can be defined as given below.
E.g. - //service[@tags='axis,test']
- It is also possible to define a registry location look up for resources or collections in that location. For an instance //governance/trunk/ would list out all the resources and collections under the governance/trunk location.
- Another advantage in searching using XPath Query is that the ability to get associations and dependencies of a resource.
In order to result all the services which has usedBy type association the following query can be used.
E.g. - //service/usedBy
And in order to result dependencies of the services created by the user 'testUser' the following query can be used.
E.g. - //service[@author = 'testUser']/depends
- Given below is a sample code segment which executes a XPath Query for search.