translators
translators copied to clipboard
update DOI handling in EndnoteXML
Currently, the Endnote XML import does't seem to import DOIs for certain document types (e.g. books, book chapters, generic documents). As discussed in the forums it would make sense to add them to Extra
instead,. which is what this PR does. Maybe there's a better way to support this. If so, I'll happily make the necessary adjustments.
Why are the tests failing? The error message is not particularly helpful...
tests on import translators are broken
Ok, so at least it's not a problem with the code.
Is this the right way to add the DOI to Extra
or is there a better way?
Regarding the other thing mentioned in the forums: what should we do with pub-location
? Should I also add it to Extra
for certain types?
Bump. Any chance this could be merged soonish? (If not, I know probably just overwrite the local translator at the scholar's installation who needs this feature, but I thought I'd ask anyway...)
Is there something I should improve?
And what about the remaining issue (pub-location
)?
Just setting item.DOI
no matter whether the item type claims to support it should work:
if (zfield == 'DOI' || ZU.fieldIsValidForType(zfield, newItem.itemType)) {
pub-location
is CSL publisher-place
("Geographic location of the publisher")? If so, setting item.place
or Place:
in extra
should work.
Just setting
item.DOI
no matter whether the item type claims to support it should work:if (zfield == 'DOI' || ZU.fieldIsValidForType(zfield, newItem.itemType)) {
You mean on line 559, right?
I've just tried it, but with that the last test doesn't work anymore.
pub-location
is CSLpublisher-place
("Geographic location of the publisher")? If so, settingitem.place
orPlace:
inextra
should work.
Indeed. It should correspond to publisher-place
. (My question wasn't so much about how to add it, but rather if it should be added. @adam3smith raised some concerns about this on the forums, at least the question is if it should be added to all types (like the DOI), or if if should be added only for some types (like conferences papers).
The test will probably fail because the DOI doesn't get added to extra
in the test environment. It should get added in an actual translation environment.
Also, we need to trim the value we put in extra
, if we stick with that - node.textContent.trim()
- because there's an extra newline between DOI:
and the DOI right now.
I can't push changes because this PR is from master
in your fork (please create a new feature branch in the future!), but here's a diff:
diff --git a/Endnote XML.js b/Endnote XML.js
index 2d168490..df898187 100644
--- a/Endnote XML.js
+++ b/Endnote XML.js
@@ -567,7 +567,7 @@ function importNext(records, index, resolve, reject) {
} else {
if (zfield == 'DOI') {
newItem.extra = (newItem.extra || '')
- + `DOI: ${node.textContent}\n`;
+ + `DOI: ${node.textContent.trim()}\n`;
} else {
notecache.push(field + ": " + processField(node));
}
@@ -680,7 +680,7 @@ function importNext(records, index, resolve, reject) {
}
} else if (field == "label") {
newItem.extra = (newItem.extra || '')
- + `Citation Key: ${node.textContent}\n`;
+ + `Citation Key: ${node.textContent.trim()}\n`;
} else if (field == "database" || field == "source-app" || field == "rec-number" || field == "ref-type"
|| field == "foreign-keys"){
//skipping these fields
@@ -1446,7 +1446,7 @@ var testCases = [
"ISBN": "978-94-017-8911-0",
"abstractNote": "It is a common assertion that being successful in one’s work and occupational career should enhance a person’s well-being. After introducing the constructs of subjective well-being and of career success studies concerned with their relationship are reviewed. We find that objective measures of career success (income) have a small positive influence on subjective well-being that is, however, moderated and mediated by goals, personality, and an individual’s rank on the income ladder in a country. We further find that the subjective experiencing of career success has an influence on well-being. Finally, the relationship of career success and well-being seems to be reciprocal and the influence of well-being on career success might even be stronger than the reverse influence of career success on well-being. We conclude that striving for career success is one means of enhancing well-being. However, there are still many open questions and further research on the interrelationship of career success and subjective well-being is needed.",
"bookTitle": "Psychological, Educational, and Sociological Perspectives on Success and Well-Being in Career Development",
- "extra": "Citation Key: \nAbele-Brehm2014\n\nDOI: \n10.1007/978-94-017-8911-0_2",
+ "extra": "Citation Key: Abele-Brehm2014\nDOI: 10.1007/978-94-017-8911-0_2",
"pages": "7-18",
"place": "Dordrecht",
"publisher": "Springer",
Thanks for the diff.
I've now had a chance to test your suggestion from above:
Just setting
item.DOI
no matter whether the item type claims to support it should work:if (zfield == 'DOI' || ZU.fieldIsValidForType(zfield, newItem.itemType)) {
Indeed, that works and this is obviously much easier than the workaround in this PR.
I guess I should use this approach then. Should I also convert the label
/citation key
handling to this method? But will we deal with the failing tests then?