org.xmldb.api.sdk.modules

Class SimpleXPathQueryService

public abstract class SimpleXPathQueryService extends SimpleConfigurable implements XPathQueryService

XPathQueryService is a Service that enables the execution of XPath queries within the context of a Collection.
Field Summary
protected Stringversion
Constructor Summary
SimpleXPathQueryService()
Method Summary
voidclearNamespaces()
Removes all namespace mappings stored in the internal namespace map.
StringgetName()
Returns the service name
StringgetNamespace(String prefix)
Returns the URI string associated with prefix.
StringgetVersion()
Returns the version of the Service
ResourceSetquery(String query)
Run an XPath query againt the Collection.
ResourceSetqueryResource(String id, String query)
Run an XPath query against an XML resource stored in the Collection associated with this service.
voidremoveNamespace(String prefix)
Removes the namespace mapping associated with prefix.
voidsetCollection(Collection col)
Sets the Collection attribute of the Service object
voidsetNamespace(String prefix, String uri)
Sets a namespace mapping in the internal namespace map used to evaluate queries.

Field Detail

version

protected String version

Constructor Detail

SimpleXPathQueryService

public SimpleXPathQueryService()

Method Detail

clearNamespaces

public void clearNamespaces()
Removes all namespace mappings stored in the internal namespace map.

Throws: XMLDBException with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getName

public String getName()
Returns the service name

getNamespace

public String getNamespace(String prefix)
Returns the URI string associated with prefix.

Parameters: prefix The prefix to retrieve from the namespace map.

Returns: The URI associated with prefix

getVersion

public String getVersion()
Returns the version of the Service

query

public ResourceSet query(String query)
Run an XPath query againt the Collection. The result is a ResourceIterator containing the results of the query.

Parameters: query The XPath query string to use.

Returns: A ResourceIterator containing the results of the query.

queryResource

public ResourceSet queryResource(String id, String query)
Run an XPath query against an XML resource stored in the Collection associated with this service. The result is a ResourceSet containing the results of the query.

Parameters: query The XPath query string to use. id The id of the document to run the query against.

Returns: A ResourceSet containing the results of the query.

removeNamespace

public void removeNamespace(String prefix)
Removes the namespace mapping associated with prefix.

Parameters: prefix The prefix to remove from the namespace map. If prefix is null or empty the mapping for the default namespace will be removed.

setCollection

public void setCollection(Collection col)
Sets the Collection attribute of the Service object

Parameters: col The new Collection value

Throws: XMLDBException with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

setNamespace

public void setNamespace(String prefix, String uri)
Sets a namespace mapping in the internal namespace map used to evaluate queries.

Parameters: prefix The prefix to set in the map. If prefix is empty or null the default namespace will be associated with the provided URI. uri The URI for the namespace to be associated with prefix.