Пример #1
0
  /**
   * Run the query returning the results as an EventIterator
   *
   * @param controller The Controller used to run the query
   * @param dynamicEnv the XQuery dynamic context for evaluating the query
   * @return an EventIterator representing the results of the query as a sequence of events
   */
  public EventIterator iterateEvents(Controller controller, DynamicQueryContext dynamicEnv)
      throws XPathException {
    if (isUpdating) {
      throw new XPathException("Cannot call iterateEvents() on an updating query");
    }
    initializeController(dynamicEnv, controller);

    XPathContextMajor context = initialContext(dynamicEnv, controller);

    // In tracing/debugging mode, evaluate all the global variables first
    if (controller.getTraceListener() != null) {
      controller.preEvaluateGlobals(context);
    }

    context.openStackFrame(stackFrameMap);

    final Configuration config = executable.getConfiguration();

    EventIterator ei = expression.iterateEvents(context);
    // ei = new TracingEventIterator(EventStackIterator.flatten(ei));
    return new ComplexContentProcessor(config, ei);
  }