This gives me a Document object with a top level node with no child nodes:
public static Document getDocument(Object jaxb) { DocumentBuilderFactory dbf =
try this
DOMResult res = new DOMResult(); JAXBContext context = JAXBContext.newInstance(obj.getClass()); context.createMarshaller().marshal(obj, res); Document doc = (Document) res.getNode();