*/
public static void marshalDocument(Writer writer, String rootTag,
Object content) throws IOException {
XmlWriter xmlWriter = getXmlWriter(writer);
try {
xmlWriter.startDocument();
marshal(xmlWriter, rootTag, content);
xmlWriter.endDocument(); // calls flush()
} catch (SAXException e) {
if (e.getException() instanceof IOException) {
// e.g. broken tcp connection