Exemplo n.º 1
0
  /**
   * Run the query in pull mode.
   *
   * <p>
   *
   * <p>For maximum effect this method should be used when lazyConstructionMode has been set in the
   * Configuration.
   *
   * <p>
   *
   * <p><b>Note: this method usually has very similar performance to the {@link
   * #run(DynamicQueryContext,javax.xml.transform.Result,java.util.Properties)} method (which does
   * the same thing), but sometimes it is significantly slower. Therefore, the run() method is
   * preferred.</b>
   *
   * @param dynamicEnv the dynamic context for query evaluation
   * @param destination the destination of the query results
   * @param outputProperties the serialization parameters
   * @see Configuration#setLazyConstructionMode(boolean)
   */
  public void pull(DynamicQueryContext dynamicEnv, Result destination, Properties outputProperties)
      throws XPathException {
    if (isUpdating) {
      throw new XPathException("Cannot call pull() on an updating query");
    }
    Configuration config = dynamicEnv.getConfiguration();
    try {
      Controller controller = newController();
      // initializeController(dynamicEnv, controller);
      EventIterator iter = iterateEvents(controller, dynamicEnv);
      // iter = new Decomposer(iter, config);

      Properties actualProperties = validateOutputProperties(controller, outputProperties);
      SerializerFactory sf = config.getSerializerFactory();
      PipelineConfiguration pipe = config.makePipelineConfiguration();
      pipe.setSerializing(true);
      Receiver receiver = sf.getReceiver(destination, pipe, actualProperties);

      receiver = new NamespaceReducer(receiver);
      if ("yes".equals(actualProperties.getProperty(SaxonOutputKeys.WRAP))) {
        receiver = new SequenceWrapper(receiver);
        // receiver = new TracingFilter(receiver);
      } else {
        receiver = new TreeReceiver(receiver);
      }
      EventIteratorToReceiver.copy(iter, (SequenceReceiver) receiver);
    } catch (XPathException err) {
      config.reportFatalError(err);
      throw err;
    }
  }
Exemplo n.º 2
0
  /**
   * Run the query in pull mode.
   *
   * <p>
   *
   * <p>For maximum effect this method should be used when lazyConstructionMode has been set in the
   * Configuration.
   *
   * <p>
   *
   * <p><b>Note: this method usually has very similar performance to the {@link
   * #run(DynamicQueryContext,javax.xml.transform.Result,java.util.Properties)} method (which does
   * the same thing), but sometimes it is significantly slower. Therefore, the run() method is
   * preferred.</b>
   *
   * @param dynamicEnv the dynamic context for query evaluation
   * @param destination the destination of the query results
   * @param outputProperties the serialization parameters
   * @see Configuration#setLazyConstructionMode(boolean)
   */
  public void pullOLD(
      DynamicQueryContext dynamicEnv, Result destination, Properties outputProperties)
      throws XPathException {
    try {
      SequenceIterator iter = iterator(dynamicEnv);
      PullProvider pull = new PullFromIterator(iter);
      pull = new PullNamespaceReducer(pull);
      final Configuration config = executable.getConfiguration();
      pull.setPipelineConfiguration(config.makePipelineConfiguration());

      SerializerFactory sf = config.getSerializerFactory();
      Receiver receiver =
          sf.getReceiver(destination, pull.getPipelineConfiguration(), outputProperties);

      //            NamespaceReducer reducer = new NamespaceReducer();
      //            PipelineConfiguration pipe = pull.getPipelineConfiguration();
      //            reducer.setPipelineConfiguration(pipe);
      //            reducer.setUnderlyingReceiver(receiver);
      //            ComplexContentOutputter outputter = new ComplexContentOutputter();
      //            outputter.setReceiver(reducer);
      //            outputter.setPipelineConfiguration(pipe);
      Receiver outputter = receiver;
      if ("yes".equals(outputProperties.getProperty(SaxonOutputKeys.WRAP))) {
        receiver = new SequenceWrapper(outputter);
      } else {
        // receiver = new TreeReceiver(outputter);
      }
      new PullPushCopier(pull, receiver).copy();
    } catch (UncheckedXPathException e) {
      throw e.getXPathException();
    }
  }