/** Configures the pipeline. */
  protected void configurePipeline() {
    // create appropriate scanner
    // and register it as one of the components.
    if (fFeatures.get(NAMESPACES) == Boolean.TRUE) {
      if (fNamespaceScanner == null) {
        fNamespaceScanner = new XMLNSDocumentScannerImpl();
        addComponent((XMLComponent) fNamespaceScanner);
      }
      fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner);
      fNamespaceScanner.setDTDValidator(null);
      fScanner = fNamespaceScanner;
    } else {
      if (fNonNSScanner == null) {
        fNonNSScanner = new XMLDocumentScannerImpl();
        addComponent((XMLComponent) fNonNSScanner);
      }
      fProperties.put(DOCUMENT_SCANNER, fNonNSScanner);
      fScanner = fNonNSScanner;
    }

    fScanner.setDocumentHandler(fDocumentHandler);
    fLastComponent = fScanner;
    // setup dtd pipeline
    if (fDTDScanner != null) {
      fDTDScanner.setDTDHandler(fDTDHandler);
      fDTDScanner.setDTDContentModelHandler(fDTDContentModelHandler);
    }
  } // configurePipeline()
  /**
   * Parses the document in a pull parsing fashion.
   *
   * @param complete True if the pull parser should parse the remaining document completely.
   * @return True if there is more document to parse.
   * @exception XNIException Any XNI exception, possibly wrapping another exception.
   * @exception IOException An IO exception from the parser, possibly from a byte stream or
   *     character stream supplied by the parser.
   * @see #setInputSource
   */
  public boolean parse(boolean complete) throws XNIException, IOException {
    //
    // reset and configure pipeline and set InputSource.
    if (fInputSource != null) {
      try {
        // resets and sets the pipeline.
        reset();
        fScanner.setInputSource(fInputSource);
        fInputSource = null;
      } catch (XNIException ex) {
        if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
        throw ex;
      } catch (IOException ex) {
        if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
        throw ex;
      } catch (RuntimeException ex) {
        if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
        throw ex;
      } catch (Exception ex) {
        if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
        throw new XNIException(ex);
      }
    }

    try {
      return fScanner.scanDocument(complete);
    } catch (XNIException ex) {
      if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
      throw ex;
    } catch (IOException ex) {
      if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
      throw ex;
    } catch (RuntimeException ex) {
      if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
      throw ex;
    } catch (Exception ex) {
      if (PRINT_EXCEPTION_STACK_TRACE) ex.printStackTrace();
      throw new XNIException(ex);
    }
  } // parse(boolean):boolean