## org.exist.xmldb
Interface XPathQueryServiceImpl

All Superinterfaces:
  Configurable, Service, XPathQueryService

All Known Implementing Classes:
  LocalXPathQueryService, RemoteXPathQueryService

public interface XPathQueryServiceImpl
extends XPathQueryService

Extends `XPathQueryService` by additional methods specific to eXist.

Author:
  Wolfgang <wolfgang@exist-db.org>

Field Summary

Fields inherited from interface org.xmldb.api.modules.XPathQueryService
`SERVICE_NAME`

Method Summary
`void` `beginProtected()` Execute all following queries in a protected environment.
`void` `declareVariable(java.lang.String qname, java.lang.Object initialValue)` Declare an external XPath variable and assign a value to it.
`void` `endProtected()` Close the protected environment.
`ResourceSet` `query(java.lang.String query, java.lang.String sortExpr)` Process an XPath query and sort the results by applying a second XPath expression to each of the search results.
`ResourceSet` `query(XMLResource res, java.lang.String query)` Process an XPath query based on the result of a previous query.
`ResourceSet` `query(XMLResource res, java.lang.String query, java.lang.String sortExpr)` Process an XPath query based on the result of a previous query and sort the results using the second XPath expression.

Methods inherited from interface org.xmldb.api.modules.XPathQueryService
`clearNamespaces, getNamespace, query, queryResource, removeNamespace, setNamespace`

Methods inherited from interface org.xmldb.api.base.Service
`getName, getVersion, setCollection`

Methods inherited from interface org.xmldb.api.base.Configurable
`getProperty, setProperty`

Method Detail

### query

    public ResourceSet query(XMLResource res,
                             java.lang.String query)
                      throws XMLDBException

  Process an XPath query based on the result of a previous query. The XMLResource contains the result received from a previous query.

  Parameters:
    `res` - an XMLResource as obtained from a previous query.
    `query` - the XPath query
  Throws:
    `XMLDBException`

### query

    public ResourceSet query(XMLResource res,
                             java.lang.String query,
                             java.lang.String sortExpr)
                      throws XMLDBException

  Process an XPath query based on the result of a previous query and sort the results using the second XPath expression. The XMLResource contains the result received from a previous query.

  Parameters:
    `res` - an XMLResource as obtained from a previous query
    `query` - the XPath query
    `sortExpr` - another XPath expression, which is executed relative to the results of the primary expression. The result of applying sortExpr is converted to a string value, which is then used to sort the results.
  Throws:
    `XMLDBException`

### query

    public ResourceSet query(java.lang.String query,
                             java.lang.String sortExpr)
                      throws XMLDBException

  Process an XPath query and sort the results by applying a second XPath expression to each of the search results. The result of applying the sort expression is converted into a string, which is then used to sort the set of results.

  Parameters:
    `query` - the XPath query
    `sortExpr` - another XPath expression, which is executed relative to the results of the primary expression.
  Throws:
    `XMLDBException`

### declareVariable

    public void declareVariable(java.lang.String qname,
                                java.lang.Object initialValue)
                         throws XMLDBException

  Declare an external XPath variable and assign a value to it. A variable can be referenced inside an XPath expression as $variable. For example, if you declare a variable with

       	declareVariable("name", "HAMLET");

  you may use the variable in an XPath expression as follows:

       	//SPEECH[SPEAKER=$name]

  Any Java object may be passed as initial value. The query engine will try to map this into a corresponding XPath value. You may also pass an XMLResource as obtained from another XPath expression. This will be converted into a node.

  Parameters:
    `qname` - a valid QName by which the variable is identified. Any prefix should have been mapped to a namespace, i.e. if a variable is called x:name, there should be a prefix/namespace mapping for the prefix x
    `initialValue` - the initial value, which is assigned to the variable
  Throws:
    `XMLDBException`

### beginProtected

    public void beginProtected()

  Execute all following queries in a protected environment. Protected means: it is guaranteed that documents referenced by the query or the result set are not modified by other threads until `endProtected()` is called.

### endProtected

    public void endProtected()

  Close the protected environment. All locks held by the current thread are released. The result set is no longer guaranteed to be stable.

Copyright (C) Wolfgang Meier. All rights reserved.