diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e933d3e90f..d7b09c72cf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue with opacity of disabled icon-buttons [#7195](https://github.com/JabRef/jabref/issues/7195) - We fixed an issue where journal abbreviations in UTF-8 were not recognized [#5850](https://github.com/JabRef/jabref/issues/5850) - We fixed an issue where the article title with curly brackets fails to download the arXiv link (pdf file). [#7633](https://github.com/JabRef/jabref/issues/7633) +- We fixed an issue where urls must be embedded in a style tag when importing EndNote style Xml files. Now it can parse url with or without a style tag. [#6199](https://github.com/JabRef/jabref/issues/6199) - We fixed an issue where the article title with colon fails to download the arXiv link (pdf file). [#7660](https://github.com/JabRef/issues/7660) ### Removed diff --git a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java index 0f673938c9a..7123b48cfa2 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java @@ -260,10 +260,30 @@ private Optional getUrl(Record record) { } private Optional getUrlValue(Url url) { - return Optional.ofNullable(url) - .map(Url::getStyle) - .map(Style::getContent) - .map(this::clean); + Optional> urlContent = Optional.ofNullable(url).map(Url::getContent); + List list = urlContent.orElse(Collections.emptyList()); + Optional ret; + if (list.size() == 0) { + return Optional.empty(); + } else { + boolean isStyleExist = false; + int style_index = -1; + for (int i = 0; i < list.size(); i++) { + if (list.get(i) instanceof Style) { + isStyleExist = true; + style_index = i; + } + } + if (!isStyleExist) { + ret = Optional.ofNullable((String) list.get(0)) + .map(this::clean); + } else { + ret = Optional.ofNullable((Style) list.get(style_index)) + .map(Style::getContent) + .map(this::clean); + } + } + return ret; } private List getKeywords(Record record) { diff --git a/src/main/resources/xjc/endnote/endnote.xsd b/src/main/resources/xjc/endnote/endnote.xsd index 5cfbe1893ca..a446559044d 100644 --- a/src/main/resources/xjc/endnote/endnote.xsd +++ b/src/main/resources/xjc/endnote/endnote.xsd @@ -668,7 +668,7 @@ - + diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.bib b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.bib new file mode 100644 index 00000000000..f93199db1af --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.bib @@ -0,0 +1,16 @@ +@article{, + abstract = {test abstract}, + author = {Ahmad, AS and Ormiston-Smith, N and Sasieni, PD}, + doi = {10.1038/bjc.2014.606}, + file = {:file\://localhost/Users/user/Documents/Bookends/Attachments/Ahmad%20et%20al%202015.pdf:PDF}, + isbn = {1532-1827 (Electronic) 0007-0920 (Linking)}, + keywords = {Age Factors; Aged; Aged, 80 and over; Female; Great Britain/epidemiology; Humans; Male; Middle Aged; Models, Statistical; Neoplasms/*epidemiology; Risk Assessment; Risk Factors; Sex Characteristics}, + number = {5}, + pages = {943-7}, + title = {Trends in the lifetime risk of developing cancer in Great Britain: comparison of risk for those born from 1930 to 1960}, + volume = {112}, + year = {2015}, + journal = {Br J Cancer}, + note = {some notes}, + url = {http://www.ncbi.nlm.nih.gov/pubmed/25647015}, +} diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.xml b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.xml new file mode 100644 index 00000000000..768ba5af391 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.xml @@ -0,0 +1,129 @@ + + + + + Library1.bdb + Bookends + 2954 + 17 + + + + + + + + + + + + + + + + + + + <style face="normal" size="100%">Trends in the lifetime risk of developing cancer in Great Britain: + comparison of risk for those born from 1930 to 1960 + </style> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://localhost/Users/user/Documents/Bookends/Attachments/Ahmad%20et%20al%202015.pdf + + + + + + + + + + + + + + + diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.bib b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.bib new file mode 100644 index 00000000000..a7293b79f14 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.bib @@ -0,0 +1,24 @@ +@article{, + author = {Chapman, A. G.}, + isbn = {0012-9658}, + number = {1}, + pages = {93-105}, + title = {An ecological basis for reforestation of submariginal lands in the Central Hardwood Region}, + volume = {18}, + year = {1937}, + journal = {Ecology}, + note = {some notes}, + url = {://000200148800007} +} +@book{, + author = {Strohecker, H. F.}, + isbn = {0012-9658}, + number = {1}, + journal = {Ecology}, + note = {some other notes}, + pages = {162-168}, + title = {A survey of soil temperatures in the Chicago area}, + volume = {18}, + url = {://000200148800014}, + year = {1937} +} diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.xml b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.xml new file mode 100644 index 00000000000..1050edd3f0f --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.xml @@ -0,0 +1,184 @@ + + + + + EndNote + Ecology.enl + + EndNote + 13264 + + 13264 + + 17 + + + + + + + + + + + + + <style face="normal" font="default" size="100%">An ecological basis for reforestation of + submariginal lands in the Central Hardwood Region + </style> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <Go to ISI>://000200148800007 + + + + + + + + + EndNote + Ecology.enl + + EndNote + 13265 + + 13265 + + 6 + + + + + + + + + + + + + <style face="normal" font="default" size="100%">A survey of soil temperatures in the Chicago area + </style> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <Go to ISI>://000200148800014 + + + + + + + + +