public void output(Document doc, Writer out) throws IOException {

    printDeclaration(out, doc, CharsetToolkit.UTF8);

    // Print out root element, as well as any root level
    // comments and processing instructions,
    // starting with no indentation
    List content = doc.getContent();
    int size = content.size();
    for (int i = 0; i < size; i++) {
      Object obj = content.get(i);

      if (obj instanceof Element) {
        printElement(out, doc.getRootElement(), 0,
                     createNamespaceStack());
      }
      else if (obj instanceof DocType) {
        printDocType(out, doc.getDocType());
        // Always print line separator after declaration, helps the
        // output look better and is semantically inconsequential
        out.write(getLineSeparator());
      }
      else {
        // XXX if we get here then we have a illegal content, for
        //     now we'll just ignore it
      }

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

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