Package org.xmldb.api.modules
Interface XPathQueryService
- All Superinterfaces:
Configurable
,Service
- All Known Implementing Classes:
SimpleXPathQueryService
,XPathQueryServiceImpl
XPathQueryService is a
Service
that enables the execution of
XPath queries within the context of a Collection
or against a
single XML Resource
stored in the Collection
.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes all namespace mappings stored in the internal namespace map.getNamespace
(String prefix) Returns the URI string associated withprefix
from the internal namespace map.Run an XPath query against theCollection
.queryResource
(String id, String query) Run an XPath query against an XML resource stored in theCollection
associated with this service.void
removeNamespace
(String prefix) Removes the namespace mapping associated withprefix
from the internal namespace map.void
setNamespace
(String prefix, 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, setProperty
Methods inherited from interface org.xmldb.api.base.Service
getName, getVersion, setCollection
-
Field Details
-
SERVICE_NAME
- See Also:
-
-
Method Details
-
setNamespace
Sets a namespace mapping in the internal namespace map used to evaluate queries. Ifprefix
is null or empty the default namespace is associated with the provided URI. A null or emptyuri
results in an exception being thrown.- Parameters:
prefix
- The prefix to set in the map. Ifprefix
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.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
TODO: probably need some special error here.
-
getNamespace
Returns the URI string associated withprefix
from the internal namespace map. Ifprefix
is null or empty the URI for the default namespace will be returned. If a mapping for theprefix
can 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_ERROR
for any vendor specific errors that occur.
-
removeNamespace
Removes the namespace mapping associated withprefix
from the internal namespace map. Ifprefix
is null or empty the mapping for the default namespace will be removed.- Parameters:
prefix
- The prefix to remove from the namespace map. Ifprefix
is null or empty the mapping for the default namespace will be removed.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
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.
-
query
Run an XPath query against theCollection
. The XPath will be applied to all XML resources stored in theCollection
. The result is aResourceSet
containing the results of the query. Any namespaces used in thequery
string will be evaluated using the mappings setup usingsetNamespace
.- Parameters:
query
- The XPath query string to use.- Returns:
- A
ResourceSet
containing the results of the query. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
queryResource
Run an XPath query against an XML resource stored in theCollection
associated with this service. The result is aResourceSet
containing the results of the query. Any namespaces used in thequery
string 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
ResourceSet
containing the results of the query. - Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-