translators icon indicating copy to clipboard operation
translators copied to clipboard

update DOI handling in EndnoteXML

Open denismaier opened this issue 1 year ago • 11 comments

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.

denismaier avatar Dec 07 '23 13:12 denismaier

Why are the tests failing? The error message is not particularly helpful...

denismaier avatar Dec 07 '23 13:12 denismaier

tests on import translators are broken

adam3smith avatar Dec 07 '23 14:12 adam3smith

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?

denismaier avatar Dec 07 '23 15:12 denismaier

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)?

denismaier avatar Jan 23 '24 14:01 denismaier

Just setting item.DOI no matter whether the item type claims to support it should work:

if (zfield == 'DOI' || ZU.fieldIsValidForType(zfield, newItem.itemType)) {

AbeJellinek avatar Jan 24 '24 16:01 AbeJellinek

pub-location is CSL publisher-place ("Geographic location of the publisher")? If so, setting item.place or Place: in extra should work.

AbeJellinek avatar Jan 24 '24 16:01 AbeJellinek

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.

denismaier avatar Jan 31 '24 10:01 denismaier

pub-location is CSL publisher-place ("Geographic location of the publisher")? If so, setting item.place or Place: in extra 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).

denismaier avatar Jan 31 '24 10:01 denismaier

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.

AbeJellinek avatar Feb 08 '24 18:02 AbeJellinek

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",

AbeJellinek avatar Mar 25 '24 19:03 AbeJellinek

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?

denismaier avatar Mar 28 '24 12:03 denismaier