* @throws IOException if there are problems writing to the file.
*/
public void write(MappingDocument doc, PrintWriter stream) throws IOException {
try {
XMLOutputFactory xof = XMLOutputFactory.newInstance();
writer = xof.createXMLStreamWriter(stream);
writer.writeStartDocument("UTF-8", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
writer.writeStartElement(ELEM_ROOT);
writeElement(MappingNodeConstants.Tags.DOCUMENT_ENCODING, doc.getDocumentEncoding());
writeElement(MappingNodeConstants.Tags.FORMATTED_DOCUMENT, Boolean.toString(doc.isFormatted()));
loadNode(doc.getRootNode());