-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle custom fields in Citavi 5 XML.js #3183
base: master
Are you sure you want to change the base?
Conversation
Custom fields (=Freitextfelder) in Citavi can be defined and used. This changes imports them as well in Zotero.
Also fixing potential problems handling keywords with other tags in general.
I have pushed now some further improvements to the Citavi translator. Most fixed issues are from the forum post https://forums.zotero.org/discussion/comment/449182/#Comment_449182 and the provided example. Additionally saving the BibTeX key was mentioned in another round and I picked this up to include it now in the official translator. It would be great to hear any feedback to this pull request. |
2cd7b19
to
fc0978d
Compare
fc0978d
to
06adfb9
Compare
Bump It would be great if this could be discussed and merged. I know that there probably more and more people will need to migrate from Citavi as several contracts in Germany ended or will end soon. This PR improves several things which were reported from such people. CC @adam3smith |
This all looks good to me -- could we either get a test or at a minimum link to test data (ideally linked from a comment in the tranlsator)? That'd help hugely with maintenance. |
var label = rememberCustomFields[field]; | ||
var customField = ZU.xpathText(references[i], './' + field); | ||
if (customField) { | ||
item.notes.push({ note: label + ": " + customField, tags: ["#CustomField"] }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't typically add automatic tags to notes AFAIK, especially with a hash prefix. Can we leave it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we do for RIS and Endnote XML to allow quick filter and delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar tags in notes are used already in this Citavi translator itself: #Notes, #TableOfContents, #Evaluation, and #todo (from tasks imported as standalone notes). There are different fields in Citavi which are all mapped to notes in Zotero. With the tags one can still differentiate them and possibly also filter for them as @adam3smith suggested.
I think that this is especially useful for custom fields, which in some cases have a better field in Zotero to save the information. This now could then be realized by using a little script after the import translator here. For example I started with this adaptable proof-of-concept script for moving the #customFields notes to some other field within Zotero. Overall, one would then need to do the import first (which is the same for everyone), and possibly some individual script to move some notes further afterwards.
The custom fields are already part of some of the saved test cases now. However, I can also check whether it is possible to provide another example covering the things here. |
But then they should up in changed tests, no? In that case, maybe just need to update the tests, or am I misunderstanding what you're saying? |
No, the test cases are not part of the translator here. I think there was an parsing error when we first tried that, but I can't remember exactly because that was some years ago. Instead test data for Citavi translator is saved in some gists and then just linked here as comments in the translator: Lines 42 to 49 in d955310
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposal for further extension of the translator to take into account image notes.
importCategories({ categories, doc, progress }); | ||
} | ||
|
||
function extractNote(doc, noteXML, rememberTags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One major drawback when import data from Citavi to Zotero is loosing all knowledge-items with images ("Bildzitat"). As far as I am aware, it is currently not possible to attach an image to a note, which results in many notes without much content after import. To simplify manual fixing afterward, I suggest tagging the note and include the filename into the note, as follows. The result could look like
noteObject.id = ZU.xpathText(noteXML, '@id'); | ||
var title = ZU.xpathText(noteXML, 'CoreStatement'); | ||
var text = ZU.xpathText(noteXML, 'Text'); | ||
var pages = extractPages(ZU.xpathText(noteXML, 'PageRange')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var pages = extractPages(ZU.xpathText(noteXML, 'PageRange')); | |
var pages = extractPages(ZU.xpathText(noteXML, 'PageRange')); | |
var address = ZU.xpathText(citations[j], 'Address'); | |
var hasMissingImage =false; |
if (text) { | ||
text = text.split(/\r?\n/).join("<br />"); | ||
noteObject.note += "<p>" + text + "</p>\n"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add text to note if address is file name. Empty line before text to ease inserting of image later.
} | |
} | |
if (address) { | |
var addressMap = JSON.parse(address); | |
// Based on Demo project mapping is: | |
// 1->File | |
// 5->Link | |
if (addressMap.LinkedResourceType==1){ | |
noteObject.note += "<p></p><p>" + '<strong>Missing Image with filename:</strong> </p>'; | |
noteObject.note += "<pre><code>" + addressMap.UriString + "</code></pre>\n"; | |
var hasMissingImage = true; | |
} | |
} |
for (let j = 0; j < rememberTags[noteObject.id]; j++) { | ||
noteObject.tags.append(rememberTags[noteObject.id][j]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, add a tag similar as #todo for easy filtering
} | |
} | |
if (hasMissingImage) { | |
noteObject.tags.push("#missingImage"); | |
} |
In Citavi, it is possible to define and use custom fields (=Freitextfelder). These changes provide them as well in Zotero.
The import now saves the contents into separate notes prefixed with the label of custom fields. For example: