Package org.xmldb.api.modules
Interface XPathQueryService
-
- All Superinterfaces:
Configurable,Service
public interface XPathQueryService extends Service
XPathQueryService is aServicethat enables the execution of XPath queries within the context of aCollectionor against a single XMLResourcestored in theCollection.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSERVICE_NAME
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearNamespaces()Removes all namespace mappings stored in the internal namespace map.java.lang.StringgetNamespace(java.lang.String prefix)Returns the URI string associated withprefixfrom the internal namespace map.ResourceSetquery(java.lang.String query)Run an XPath query against theCollection.ResourceSetqueryResource(java.lang.String id, java.lang.String query)Run an XPath query against an XML resource stored in theCollectionassociated with this service.voidremoveNamespace(java.lang.String prefix)Removes the namespace mapping associated withprefixfrom the internal namespace map.voidsetNamespace(java.lang.String prefix, java.lang.String uri)Sets a namespace mapping in the internal namespace map used to evaluate queries.-
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, getProperty, setProperty
-
Methods inherited from interface org.xmldb.api.base.Service
getName, getVersion, setCollection
-
-
-
-
Field Detail
-
SERVICE_NAME
static final java.lang.String SERVICE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
setNamespace
void setNamespace(java.lang.String prefix, java.lang.String uri) throws XMLDBExceptionSets a namespace mapping in the internal namespace map used to evaluate queries. Ifprefixis null or empty the default namespace is associated with the provided URI. A null or emptyuriresults in an exception being thrown.- Parameters:
prefix- The prefix to set in the map. Ifprefixis empty or null the default namespace will be associated with the provided URI.uri- The URI for the namespace to be associated with prefix.- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getNamespace
java.lang.String getNamespace(java.lang.String prefix) throws XMLDBExceptionReturns the URI string associated withprefixfrom the internal namespace map. Ifprefixis null or empty the URI for the default namespace will be returned. If a mapping for theprefixcan not be found null is returned.- Parameters:
prefix- The prefix to retrieve from the namespace map.- Returns:
- The URI associated with
prefix - Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
removeNamespace
void removeNamespace(java.lang.String prefix) throws XMLDBExceptionRemoves the namespace mapping associated withprefixfrom the internal namespace map. Ifprefixis null or empty the mapping for the default namespace will be removed.- Parameters:
prefix- The prefix to remove from the namespace map. Ifprefixis null or empty the mapping for the default namespace will be removed.- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
clearNamespaces
void clearNamespaces() throws XMLDBExceptionRemoves all namespace mappings stored in the internal namespace map.- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
query
ResourceSet query(java.lang.String query) throws XMLDBException
Run an XPath query against theCollection. The XPath will be applied to all XML resources stored in theCollection. The result is aResourceSetcontaining the results of the query. Any namespaces used in thequerystring will be evaluated using the mappings setup usingsetNamespace.- Parameters:
query- The XPath query string to use.- Returns:
- A
ResourceSetcontaining the results of the query. - Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
queryResource
ResourceSet queryResource(java.lang.String id, java.lang.String query) throws XMLDBException
Run an XPath query against an XML resource stored in theCollectionassociated with this service. The result is aResourceSetcontaining the results of the query. Any namespaces used in thequerystring will be evaluated using the mappings setup usingsetNamespace.- Parameters:
query- The XPath query string to use.id- The id of the document to run the query against.- Returns:
- A
ResourceSetcontaining the results of the query. - Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
-