/**
   * Implements javax.xml.transform.sax.TransformerHandler.setResult() Enables the user of the
   * TransformerHandler to set the to set the Result for the transformation.
   *
   * @param result A Result instance, should not be null
   * @throws IllegalArgumentException if result is invalid for some reason
   */
  public void setResult(Result result) throws IllegalArgumentException {
    _result = result;

    if (null == result) {
      ErrorMsg err = new ErrorMsg(ErrorMsg.ER_RESULT_NULL);
      throw new IllegalArgumentException(err.toString()); // "result should not be null");
    }

    if (_isIdentity) {
      try {
        // Connect this object with output system directly
        SerializationHandler outputHandler = _transformer.getOutputHandler(result);
        _transformer.transferOutputProperties(outputHandler);

        _handler = outputHandler;
        _lexHandler = outputHandler;
      } catch (TransformerException e) {
        _result = null;
      }
    } else if (_done) {
      // Run the transformation now, if not already done
      try {
        _transformer.setDOM(_dom);
        _transformer.transform(null, _result);
      } catch (TransformerException e) {
        // What the hell are we supposed to do with this???
        throw new IllegalArgumentException(e.getMessage());
      }
    }
  }