XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getDetail());
DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
writer.write(bean, part, xsw);
} else {
XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getOrCreateDetail());
DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
writer.write(bean, part, xsw);
if (!f.getDetail().hasChildNodes()) {
f.setDetail(null);
}
}