public void write(Document doc) throws IOException {
        writeDeclaration();

        if (doc.getDocType() != null) {
            indent();
            writeDocType(doc.getDocType());
        }

        for ( int i = 0, size = doc.nodeCount(); i < size; i++ ) {
            Node node = doc.node(i);
            writeNode( node );
        }
        writePrintln();

        if ( autoFlush ) {
            flush();
        }
    }
<p>This will print the <code>Document</code> to the current Writer.</p>

<p> Warning: using your own Writer may cause the writer's
preferred character encoding to be ignored.  If you use
encodings other than UTF8, we recommend using the method that
takes an OutputStream instead.  </p>

<p>Note: as with all Writers, you may need to flush() yours
after this method returns.</p>

@param doc <code>Document</code> to format.
@throws IOException - if there's any problem writing.
xmppserver/src/main/java/org/jivesoftware/util/XMLWriter.java