*/
private static Document tidyDoc(InputStream stream, boolean quiet, boolean showWarnings, boolean report_errors,
boolean isXML, OutputStream out) throws TidyException {
StringWriter sw = new StringWriter();
Tidy tidy = makeTidyParser(quiet, showWarnings, isXML, sw);
Document doc = tidy.parseDOM(stream, out);
doc.normalize();
if (tidy.getParseErrors() > 0) {
if (report_errors) {
log.error("TidyException: " + sw.toString());
throw new TidyException(tidy.getParseErrors(),tidy.getParseWarnings());