SaveSession ss = getSaveSession("UTF8", new File(file));
VerifyingWriter ps = ss.getWriter();
MODSDatabase md = new MODSDatabase(database, keySet);
try {
DOMSource source = new DOMSource(md.getDOMrepresentation());
StreamResult result = new StreamResult(ps);
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.transform(source, result);
}