Node node = xml.getWrappedNode();
Document document = (Document)node; // assume that we're given the
// entire document.
// if that's an issue, we could code something more complex.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
org.jdom.Document jDocument = new DOMBuilder().build(document);
org.jdom.output.Format format = org.jdom.output.Format.getRawFormat();
format.setEncoding("utf-8");
try {
new XMLOutputter(format).output(jDocument, baos);
} catch (IOException e) {