code: private void doXPathRes(final String resource, final Long revision, final OutputStream output,
          final boolean nodeid, final String xpath) throws TTException {
          // Storage connection to treetank
          ISession session = null;
          INodeReadTrx rtx = null;
          try {
              if (mDatabase.existsResource(resource)) {
                  session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
                  // Creating a transaction
                  if (revision == null) {
                      rtx = new NodeReadTrx(session.beginBucketRtx(session.getMostRecentVersion()));
                  } else {
                      rtx = new NodeReadTrx(session.beginBucketRtx(revision));
                  }
  
                  final AbsAxis axis = new XPathAxis(rtx, xpath);
                  for (final long key : axis) {
                      WorkerHelper.serializeXML(session, output, false, nodeid, key, revision).call();
                  }
              }
          } catch (final Exception globExcep) {
              throw new WebApplicationException(globExcep, Response.Status.INTERNAL_SERVER_ERROR);
          } finally {
              WorkerHelper.closeRTX(rtx, session);
  
          }
      }
docs: This method performs an XPath evaluation and writes it to a given output
  stream.
  
  @param resource
  The existing resource.
  @param revision
  The revision of the requested document.
  @param output
  The output stream where the results are written.
  @param nodeid
  <code>true</code> if node id's have to be delivered. <code>false</code> otherwise.
  @param xpath
  The XPath expression.
  @throws TTException