use of org.jabref.logic.msbib.MSBibDatabase in project jabref by JabRef.
the class MSBibExportFormat method performExport.
@Override
public void performExport(final BibDatabaseContext databaseContext, final String file, final Charset encoding, List<BibEntry> entries) throws SaveException {
Objects.requireNonNull(databaseContext);
Objects.requireNonNull(entries);
if (entries.isEmpty()) {
return;
}
// forcing to use UTF8 output format for some problems with xml export in other encodings
SaveSession session = new FileSaveSession(StandardCharsets.UTF_8, false);
MSBibDatabase msBibDatabase = new MSBibDatabase(databaseContext.getDatabase(), entries);
try (VerifyingWriter ps = session.getWriter()) {
try {
DOMSource source = new DOMSource(msBibDatabase.getDomForExport());
StreamResult result = new StreamResult(ps);
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.transform(source, result);
} catch (TransformerException | IllegalArgumentException | TransformerFactoryConfigurationError e) {
throw new Error(e);
}
finalizeSaveSession(session, Paths.get(file));
} catch (IOException ex) {
throw new SaveException(ex);
}
}
use of org.jabref.logic.msbib.MSBibDatabase in project jabref by JabRef.
the class MsBibImporter method importDatabase.
@Override
public ParserResult importDatabase(BufferedReader reader) throws IOException {
Objects.requireNonNull(reader);
MSBibDatabase dbase = new MSBibDatabase();
return new ParserResult(dbase.importEntriesFromXml(reader));
}
Aggregations