Skip to content

Commit

Permalink
Resolves #973 Add DOI field for English version of MS Office 2007 XML
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed May 19, 2016
1 parent db7a319 commit 56d4e02
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
17 changes: 7 additions & 10 deletions src/main/java/net/sf/jabref/exporter/MSBibExportFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,24 @@ public void performExport(final BibDatabaseContext databaseContext, final String
Objects.requireNonNull(databaseContext);
Objects.requireNonNull(entries);

if (entries.isEmpty()) { // Only export if entries exist
if (entries.isEmpty()) {
return;
}
// forcing to use UTF8 output format for some problems with
// xml export in other encodings
SaveSession ss = new SaveSession(StandardCharsets.UTF_8, false);
MSBibDatabase md = new MSBibDatabase(databaseContext.getDatabase(), entries);
try (VerifyingWriter ps = ss.getWriter()) {

// PS: DOES NOT SUPPORT EXPORTING ONLY A SET OF ENTRIES
// forcing to use UTF8 output format for some problems with xml export in other encodings
SaveSession session = new SaveSession(StandardCharsets.UTF_8, false);
MSBibDatabase msBibDatabase = new MSBibDatabase(databaseContext.getDatabase(), entries);

try (VerifyingWriter ps = session.getWriter()) {
try {
DOMSource source = new DOMSource(md.getDOMrepresentation());
DOMSource source = new DOMSource(msBibDatabase.getDOMrepresentation());
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(ss, new File(file));
finalizeSaveSession(session, new File(file));
} catch (SaveException | IOException ex) {
throw new IOException(ex.getMessage());
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class MSBibEntry {
private String thesisType;
private String internetSiteTitle;
private String dateAccessed;
private String doi;
private String url;
private String productionCompany;
private String publicationTitle;
Expand Down Expand Up @@ -267,6 +268,7 @@ private void populateFromXml(Element entry, String bcol) {
dateAccessed = null;
}

doi = getFromXml(bcol + "DOI", entry);
url = getFromXml(bcol + "URL", entry);
productionCompany = getFromXml(bcol + "ProductionCompany", entry);

Expand Down Expand Up @@ -434,8 +436,11 @@ private void populateFromBibtex(BibEntry bibtex) {
if (bibtex.hasField(MSBIB + "accessed")) {
dateAccessed = bibtex.getField(MSBIB + "accessed");
}
if (bibtex.hasField("doi")) {
doi = bibtex.getField("doi");
}
if (bibtex.hasField("url")) {
url = bibtex.getField("url"); /* SM: 2010.10: lower case */
url = bibtex.getField("url");
}
if (bibtex.hasField(MSBIB + "productioncompany")) {
productionCompany = bibtex.getField(MSBIB + "productioncompany");
Expand Down Expand Up @@ -539,14 +544,12 @@ private void populateFromBibtex(BibEntry bibtex) {
// http://www.microsoft.com/globaldev/reference/lcid-all.mspx
private int getLCID(String language) {
// TODO: add language to LCID mapping

return 0;
}

// http://www.microsoft.com/globaldev/reference/lcid-all.mspx
private String getLanguage(int LCID) {
// TODO: add language to LCID mapping

return "english";
}

Expand Down Expand Up @@ -797,6 +800,7 @@ public Element getDOMrepresentation(Document document) {
/* SM 2010.10 added month export */
addField(document, msbibEntry, "Month", month);

addField(document, msbibEntry, "DOI", doi);
addField(document, msbibEntry, "URL", url);
addField(document, msbibEntry, "ProductionCompany", productionCompany);
addField(document, msbibEntry, "PublicationTitle", publicationTitle);
Expand Down Expand Up @@ -1007,6 +1011,9 @@ public BibEntry getBibtexRepresentation() {
if (dateAccessed != null) {
hm.put(MSBIB + "accessed", dateAccessed);
}
if (doi != null) {
hm.put("doi", doi);
}
if (url != null) {
hm.put("url", url);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@phdthesis{2002,
title = {Agile Entwicklung Web-basierter Systeme},
year = {2002},
type = {type},
type = {type},
number = {3},
address = {a},
address = {a},
journal = {Wirtschaftsinformatik},
keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development},
language = {english},
pages = {237--248},
publisher = {Gabler Verlag},
doi = {10.1007/BF03250842},
url = {http://dx.doi.org/10.1007/BF03250842},
volume = {44},
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
<b:Author/>
<b:Pages>237-248</b:Pages>
<b:Volume>44</b:Volume>
<b:StandardNumber> DOI: 10.1007/BF03250842</b:StandardNumber>
<b:Publisher>Gabler Verlag</b:Publisher>
<b:City>a</b:City>
<b:JournalName>Wirtschaftsinformatik</b:JournalName>
<b:Issue>3</b:Issue>
<b:ThesisType>type</b:ThesisType>
<b:DOI>10.1007/BF03250842</b:DOI>
<b:URL>http://dx.doi.org/10.1007/BF03250842</b:URL>
<b:BIBTEX_KeyWords>software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development</b:BIBTEX_KeyWords>
</b:Source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<b:Publisher>Gabler Verlag</b:Publisher>
<b:JournalName>Wirtschaftsinformatik</b:JournalName>
<b:Issue>3</b:Issue>
<b:DOI>10.1000/182</b:DOI>
<b:URL>http://dx.doi.org/10.1007/BF03250842</b:URL>
<b:BIBTEX_KeyWords>software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development</b:BIBTEX_KeyWords>
</b:Source>
Expand Down

0 comments on commit 56d4e02

Please sign in to comment.