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