private static Document marshalActualDocument(Object root, Document document) throws JiBXException {
final IBindingFactory bfact = BindingDirectory.getFactory(root.getClass());
final IMarshallingContext mctx = bfact.createMarshallingContext();
final JDOMWriter jdomWriter = new JDOMWriter(bfact.getNamespaces(), document);
return marshalDocument(root, mctx, jdomWriter);
}