|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Execute XQuery expressions on the database.
This interface is similar to org.xmldb.api.modules.XPathQueryService, but
provides additional methods to compile an XQuery into an internal representation, which
can be executed repeatedly. Since XQuery scripts can be very large, compiling an expression
in advance can save a lot of time.
| Method Summary | |
CompiledExpression |
compile(java.lang.String query)
Compiles the specified XQuery and returns a handle to the compiled code, which can then be passed to #execute(CompiledExpression). |
CompiledExpression |
compileAndCheck(java.lang.String query)
Tries to compile the specified XQuery and returns a handle to the compiled code, which can then be passed to #execute(CompiledExpression). |
void |
declareVariable(java.lang.String qname,
java.lang.Object initialValue)
Declare a global, external XQuery variable and assign a value to it. |
void |
dump(CompiledExpression expression,
java.io.Writer writer)
Return a diagnostic dump of the query. |
ResourceSet |
execute(Source source)
|
ResourceSet |
execute(XMLResource res,
CompiledExpression expression)
|
java.lang.String |
getNamespace(java.lang.String prefix)
Returns the URI string associated with prefix from
the internal namespace map. |
ResourceSet |
query(java.lang.String query)
Execute the specified query and return the results as a ResourceSet. |
ResourceSet |
query(XMLResource res,
java.lang.String query)
Process a query based on the result of a previous query. |
void |
removeNamespace(java.lang.String ns)
Removes the namespace mapping associated with prefix from
the internal namespace map. |
void |
setModuleLoadPath(java.lang.String path)
|
void |
setNamespace(java.lang.String prefix,
java.lang.String namespace)
Sets a namespace mapping in the internal namespace map used to evaluate queries. |
void |
setXPathCompatibility(boolean backwardsCompatible)
Enable or disable XPath 1.0 compatibility mode. |
| Method Detail |
public ResourceSet query(java.lang.String query)
throws XMLDBException
ResourceSet.
query -
XMLDBException
public ResourceSet query(XMLResource res,
java.lang.String query)
throws XMLDBException
res - an XMLResource as obtained from a previous query.query - the XPath query
XMLDBException
public CompiledExpression compile(java.lang.String query)
throws XMLDBException
#execute(CompiledExpression).
query -
XMLDBException
public CompiledExpression compileAndCheck(java.lang.String query)
throws XMLDBException,
XPathException
#execute(CompiledExpression).
If a static error is detected, an XPathException will be thrown.
query -
XMLDBException
XPathException
public ResourceSet execute(Source source)
throws XMLDBException
XMLDBException
public ResourceSet execute(XMLResource res,
CompiledExpression expression)
throws XMLDBException
XMLDBException
public java.lang.String getNamespace(java.lang.String prefix)
throws XMLDBException
prefix from
the internal namespace map. If prefix is null or empty the
URI for the default namespace will be returned. If a mapping for the
prefix can not be found null is returned.
prefix - The prefix to retrieve from the namespace map.
prefix
XMLDBException - with expected error codes.ErrorCodes.VENDOR_ERROR for any vendor
specific errors that occur.
public void setNamespace(java.lang.String prefix,
java.lang.String namespace)
throws XMLDBException
prefix is null or empty the default namespace is
associated with the provided URI. A null or empty uri results
in an exception being thrown.
prefix - The prefix to set in the map. If
prefix is empty or null the
default namespace will be associated with the provided URI.
XMLDBException - with expected error codes.ErrorCodes.VENDOR_ERROR for any vendor
specific errors that occur.
public void removeNamespace(java.lang.String ns)
throws XMLDBException
prefix from
the internal namespace map. If prefix is null or empty the
mapping for the default namespace will be removed.
XMLDBException - with expected error codes.ErrorCodes.VENDOR_ERROR for any vendor
specific errors that occur.
public void declareVariable(java.lang.String qname,
java.lang.Object initialValue)
throws XMLDBException
declare variable
statement in the XQuery prolog.
The variable can be referenced inside the XQuery expression as
$variable. For example, if you declare a variable with
declareVariable("name", "HAMLET");
you may use the variable in an XQuery expression as follows:
//SPEECH[SPEAKER=$name]Any Java object may be passed as initial value. The implementation will try to map the Java object into a corresponding XQuery value. In particular, all basic Java types (Integer, Long, Double, String) should be mapped into the corresponding XML Schema atomic types. A Java array is mapped to an XQuery sequence. The implemenation should also recognize all DOM node types. As a special case, an XMLResource as obtained from a
ResourceSet will be
converted into a node.
qname - a valid QName by which the variable is identified. Any
prefix should have been mapped to a namespace, using setNamespace(String, String).
For example, if a variable is called x:name, a prefix/namespace mapping should have
been defined for prefix x before calling this method.initialValue - the initial value, which is assigned to the variable
XMLDBExceptionpublic void setXPathCompatibility(boolean backwardsCompatible)
backwardsCompatible - public void setModuleLoadPath(java.lang.String path)
public void dump(CompiledExpression expression,
java.io.Writer writer)
throws XMLDBException
expression - writer -
XMLDBException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||