Chapter 73. Example XMLDB data resource client

73.1. How to list the collections in an XMLDB data resource
73.2. How to list the documents in an XMLDB data resource
73.3. How to run an XPath query over the documents in an XMLDB data resource

OGSA-DAI provides a simple command-line client for running requests involving XMLDB data resources. This uses the XMLListCollections, XMLListResources, XPathQuery and DeliverToRequestStatus activities.

[Note]Note
OGSA-DAI example clients are intended to allow users to quickly test their deployment as well to provide basic examples of how to construct clients using the client toolkit. They are not intended to be robust applications for use in problem solving. OGSA-DAI offers a toolkit which provides userss with the tools to develop their own clients that use OGSA-DAI services - these clients are the simplest examples built using this toolkit.

The client takes the following arguments:

73.1. How to list the collections in an XMLDB data resource

Run the following, replacing SERVICES-BASE-URL, DATA-RESOURCE-ID, QUERY and, if required DRER-ID and COLLECTION.

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u SERVICES-BASE-URL [-e DRER-ID] -d DATA-RESOURCE-ID  \ 
  -c listCollections [-coll COLLECTION]

For example:

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c listCollections

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c listCollections -coll someSubCollection

73.2. How to list the documents in an XMLDB data resource

Run the following, replacing SERVICES-BASE-URL, DATA-RESOURCE-ID, QUERY and, if required DRER-ID and COLLECTION.

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u SERVICES-BASE-URL [-e DRER-ID] -d DATA-RESOURCE-ID  \ 
  -c listResources [-coll COLLECTION]

For example:

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c listResources

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c listResources -coll someSubCollection

73.3. How to run an XPath query over the documents in an XMLDB data resource

Run the following, replacing SERVICES-BASE-URL, DATA-RESOURCE-ID, QUERY and, if required DRER-ID and COLLECTION.

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u SERVICES-BASE-URL [-e DRER-ID] -d DATA-RESOURCE-ID  \ 
  -c xpath [-coll COLLECTION] [-r DOCUMENT] [-n PREFIX:URN, PREFIX:URN,...] \
  -x XPATH

If the optional -r DOCUMENT is provided then only that document is queried.

XPATH is the query to run. If the XPath query uses namespaces then these need to be declared using the -n PREFIX:URN, PREFIX:URN,... argument. This maps any namespace prefixes in the query to namespace URNs.

For example:

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c xpath -x "//*"

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c xpath -x "//*" -coll mySubCollection -r myDocument

$ java uk.org.ogsadai.client.toolkit.example.XMLDBClient \
  -u http://coal.epcc.ed.ac.uk:8080/wsrf/services/dai/ -d MyOwnXMLDBDataResource \
  -c xpath -coll someSubCollection -resource myDocument \
  -n myprefix:http://org.somecompany.com/XML,myprefix2:http://org.someothercompany.com/SomeOtherXML \
  -x "//*/myprefix:SomeElement/myprefix2:SomeOtherElement/"