code: private Document parse(Object xml, Element instruction, PrintWriter logger)
              throws Exception {
          Document soapMessage = null;
          String returnType = instruction.getAttribute("return");// envelope or
                                                                 // content
  
          ErrorHandlerImpl eh = new ErrorHandlerImpl("Parsing", logger);
  
          if (xml instanceof InputStream) {
              soapMessage = SoapUtils.getSOAPMessage((InputStream) xml);
          } else if (xml instanceof Document) {
              soapMessage = (Document) xml;
          } else {
              throw new Exception("Error: Invalid xml object");
          }
  
          if (soapMessage != null && isSoapFault(soapMessage)) {
              return parseSoapFault(soapMessage, logger);
          }
  
          eh.setRole("Validation");
          this.validateSoapMessage(soapMessage, eh);
  
          // Print errors
          int error_count = eh.getErrorCount();
          int warning_count = eh.getWarningCount();
          if (error_count > 0 || warning_count > 0) {
              String msg = "";
              if (error_count > 0) {
                  msg += error_count + " validation error"
                          + (error_count == 1 ? "" : "s");
                  if (warning_count > 0) {
                      msg += " and ";
                  }
              }
              if (warning_count > 0) {
                  msg += warning_count + " warning"
                          + (warning_count == 1 ? "" : "s");
              }
              msg += " detected.";
              logger.println(msg);
          }
  
          if (error_count > 0) {
              soapMessage = null;
          }
  
          if (soapMessage != null && returnType.equals("content")) {
              return SoapUtils.getSoapBody(soapMessage);
          }
  
          return soapMessage;
      }
docs: A method to parse and valdate the response of a SOAP server.
  
  @param xml
  the SOAP message to retrieve and validate. May be an
  InputStream object or a Document object.
  @param instruction
  the SOAP Parser CTL excerpt
  @param logger
  the PrintWriter to log all results to
  
  @return null if there were errors, the parsed document otherwise: it can
  be the SOAP message, the SOAP message body content or a SOAP fult
  
  @author Simone Gianfranceschi