public void output(Document doc, Writer out) throws IOException {
    printDeclaration(out, userFormat.encoding);

    // Print out root element, as well as any root level
    // comments and processing instructions,
    // starting with no indentation
    List<Content> content = doc.getContent();
    int size = content.size();
    for (int i = 0; i < size; i++) {
      Content obj = content.get(i);
      if (obj instanceof Element) {
        printElement(out, doc.getRootElement(), 0, new NamespaceStack());
      }
      else if (obj instanceof DocType) {
        printDocType(out, doc.getDocType());
        // Always print line separator after declaration, helps the
        // output look better and is semantically inconsequential
        writeLineSeparator(out);
      }

      newline(out);
      indent(out, 0);
    }

    // Output final line separator
    // We output this no matter what the newline flags say
    writeLineSeparator(out);

    out.flush();
  }
public void output(Document doc, Writer out)