Zotero to CSL type and field mappings
I needed to get a list of all fields for all item types, so instead of wasting a couple minutes looking through them on Zotero, I decided that I'll create a script that will generate this list automatically and since the current mapping is out of date, I thought it might be useful in general.
To get to the point, I ended up making a Zotero extension that outputs field mappings in an xml format, which is then transformed and styled.
It's available at https://github.com/aurimasv/z2csl where typeMap.xml is already pregenerated and typeMap.xsl and typeMap.css go along with it.
This is sort of my "hello world" extension, so I'm sure it's not the greatest piece of work out there (and if someone cares to point out some amateur mistakes, I'm excited to learn). I also lack any sort of artistic talent, so the styling is ugly, but I think it does the job.
The only thing that it lacks is mapping Zotero label to Zotero field, which for the most part is self-explanatory anyway. Other than that, it can probably replace http://gsl-nagoya-u.net/http/pub/csl-fields/
EDIT:It's also my first time using XSLT
To get to the point, I ended up making a Zotero extension that outputs field mappings in an xml format, which is then transformed and styled.
It's available at https://github.com/aurimasv/z2csl where typeMap.xml is already pregenerated and typeMap.xsl and typeMap.css go along with it.
This is sort of my "hello world" extension, so I'm sure it's not the greatest piece of work out there (and if someone cares to point out some amateur mistakes, I'm excited to learn). I also lack any sort of artistic talent, so the styling is ugly, but I think it does the job.
The only thing that it lacks is mapping Zotero label to Zotero field, which for the most part is self-explanatory anyway. Other than that, it can probably replace http://gsl-nagoya-u.net/http/pub/csl-fields/
EDIT:It's also my first time using XSLT
https://bitbucket.org/fbennett/zoterofieldmap/overview
(I posted it in the hope that someone would take up the chalice and rebuild the field assignment pages, but there's no need to revisit it if what you have is working.)
(edit: your approach will be easier to maintain, as it uses the native Zotero functions. Mine worked off the database, which was handy for avoiding the need pull data from a running Zotero instance, but made for complexity in the code.)
As an aside, I think the CSL project would really benefit from hosting something like typeMap.xml as part of the CSL specification. Currently we have no documentation on what the different CSL item types represent and how exactly they differ from each other in terms of fields. When separate pieces of software (e.g. Zotero and Mendeley) add differing sets of fields to the item types, this can lead to some unexpected differences in CSL output.
Basically we need CSL field assignments for all CSL item types. We need clear textual descriptions for each item type that make it clear how the item types differ from each other. And it would probably be helpful to provide item type-specific labels/descriptions for each of the CSL fields (these are the Zotero labels at e.g. http://gsl-nagoya-u.net/http/pub/csl-fields/map.html) to further standardize how fields are presented to users (e.g. Zotero uses the label "Publication" for the CSL variable "container-title" for the CSL item type "article-journal).
http://aurimasv.github.com/z2csl/typeMap.xml
Why?
I also fixed the CSL variable mappings discussed here.
http://aurimasv.github.com/z2csl/typeMap.xml
It will also help with writing the documentation for which types to use in Zotero for the particular uni i am writing the script for. Again, Thankyou!
The only section I would love to have added for convenience is a matrix of all CSL item types by CSL variables. The cells could contain either a "Yes" in the spots where the variable is available or the name of the actual Zotero UI label.
A second matrix could be added for all Zotero item types by Zotero UI labels and the cells could contain the CSL variable names.
Come to think about it, both of such matrices could be combined into one.
I'll see what I can do for the Zotero matrix. If you need this some time soon, you may want to try and add it yourself. It should not need any extra data from the Zotero plugin, just some more XSLT code.
I think putting in restrictions in the CSL spec might be a no-go, unless all implementations agree to revisit their data models as necessary (considering that we've been clamoring for changes to the Zotero data model for years, I don't think this is very likely).
The XSLT bit sounds tempting but I am not sure I have the required bandwidth.
Hi there,
I am struggling figuring out how Zotero fields map to CSL variables. I searched the web and found
https://github.com/aurimasv/z2csl
which sounds exactly to be what I am looking for. I am working with Zotero standalone. Could you kindly give me advice on how to install this extension.
Thanks in advance
Thomas
http://aurimasv.github.io/z2csl/typeMap.xml
Thanks a lot for that pointer. I will go for typeMap.xml
Thomas
Very nice job. thanks for your great work so far!! I'm still confused why – after all those years – there is no official mapping from Zotero or am I missing something? I think it's fundamental for creating an individual citation style which I'm want to do right now. But I'm wondering if there were changes in Zotero 7 or is your mapping from 2022 still accurate?
Between the CSL specs and this you'll be fine:
https://forums.zotero.org/discussion/93617/announcement-csl-1-0-2-launch-date
Unfortuately the add-on used to automatically create the mappings doesn't work in Zotero 7, so the page is currently missing two newly added item types: Standard and Dataset. Everything else is still correct, I believe.
@dstillman -- would one of you be willing to update the add-on? I agree we really do need an accurate mapping and with more changes coming, having the only complete mapping become outdated is going to become increasingly problematic.