docs: public static void writeXHTML(Document htmldoc, OutputStream out) throws IOException {
      javax.xml.transform.Result result = new StreamResult(out);
      // Use a transformer for pretty printing
      Transformer xformer;
      try {
        xformer = TransformerFactory.newInstance().newTransformer();
        xformer.setOutputProperty(OutputKeys.INDENT, "yes");
        // TODO: ensure the "meta" tag doesn't claim a different encoding!
        xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        xformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, HTML_XHTML_TRANSITIONAL_DOCTYPE_PUBLIC);
        xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, HTML_XHTML_TRANSITIONAL_DOCTYPE_SYSTEM);
        xformer.transform(new DOMSource(htmldoc), result);
      }
      catch(TransformerException e1) {
        throw new IOException(e1);
      }
      out.flush();
    }