Editing an existent style file

edited April 1, 2017
Hi,

I'm having a lot of difficulty getting even a basic grasp of editing a csl file to correct a few errors in the South African Medical Journal style. The style file is linked below. I'm trying to alter, for example, "cited" to "accessed on" where dates are given for citations, along with removing URLs for certain file types. I spent ages adding bits and pieces within tags like bibliography etc in the style editor in Zotero and nothing ever seemed to change - even things directly out of the style editing guide on this website.

Can anyone explain in nice and simple terms how to do something like altering "cited" to "accessed", and how to alter specific things about the bibliography. There don't seem to be any whole csl files available anywhere I can find from which to jump off and start editing - though everyone seems to know how to do it! I am probably just being exceptionally dim.

Thanks for any help you can give - I'd love to be able to start editing these as there often little tweaks needed to match a particular journal's style.

Please fine the style file here - it doesn't render if I simply post it and I don't know how to add code on this forum.

http://www.zotero.org/styles/south-african-medical-journal

Thanks
  • edited April 1, 2017
    You can start from here: https://github.com/citation-style-language/styles/wiki/Editing-Styles
    The thing with the style you mention is, that it is a dependent style of vancouver-superscript-brackets-only-year.csl.
    So you'd need to change that one. But of course many other styles are dependent of the vancouver style, so we'd probably would need to make this an indepedent style.

    You can see the difference here:
    1. The SAMJ style is rather short. Just a few info bits and points to the vancouver style in line 7: https://github.com/citation-style-language/styles/blob/master/dependent/south-african-medical-journal.csl
    2. The vancouver style (https://github.com/citation-style-language/styles/blob/master/vancouver-superscript-brackets-only-year.csl) has actually the information on how the citations should look like.


    For your specific question you would then change line 64 from <text term="cited" text-case="lowercase"/> to <text term="accessed" text-case="lowercase"/>

    You can certainly just post here in the forum and we'll make fixes, but it would be even better if you'd learned CSL and could contribute directly to the repository. :) We are happy to help.
    Check out the editors here: http://editor.citationstyles.org/about/
    You can switch between code and visual. Really helpful to get into it.
  • edited April 3, 2017
    Hi. Thanks for the helpful comments, particularly the code for the Vancouver style. That got me going. I took that and simply added the relevant bits to make references appear like South African Medical Journal - which has some unspoken differences with the Vancouver style.

    I've installed it locally and it seems to work, though it says it's not a valid CSL 1.0.1 style file which I don't understand. Anyway, how do I go about making it more widely available? It may as well be used since I think it's closer than the existing SAMJ style file.
  • http://validator.citationstyles.org/ produces reasonably helpful validation errors.
  • Hello;
    I face a related problem.
    I have a grant proposal with a 1 page limit for all references.
    I am currently using Zotero CSL:
    American Chemical Society (page-first)

    But to save space, I need a style that only includes the first 2 author's names, followed by 'et al.'.

    I failed in attempting to edit the style.
    Does anyone know of a built in style more compact?
    Or could guide me to editing the American Chemical Society (page-first)
    thanks, Doug
  • add et-al-min="3" et-al-use-first="2" to the line starting with <bibliography, e.g. right after bibliography (with a space of course)
  • Wow.
    First I found the .csl file on my harddrive, and made the edit with a text editor, and saved under a new name.
    The new .csl did not show up on my list of options.

    So then I went into Zotero Preferences, found 'Styles' and clicked 'Style Editor'.
    It defaulted to the American Chemical Society (page-first) csl.
    I made the edit you suggested, and clicked 'Save As'

    I got:

    "Error parsing style:
    Error: File is not valid XML"

    But, when I reopened my file and refreshed, the bibliography refreshed to the new format.
    So, not sure why it worked, but it worked.
  • You need to go into your edited CSL file and change the style ID and Title at the top of the file, or else your changes will be overwritten the next time the official style updates. Hat will also make the new style appear in the list.
  • Thanks, but can you be more specific as to which lines to change?
    I failed in attempting to rename the file and remove links to the previous base style.
  • At the top of the file, there are lines that start with <id> and <title>. You need to change the style ID and Title between those tags, respectively, to anything else, then reinstall the file through the Cite pane of the Zotero preferences.
  • I have tried to edit the SAGE - Harvard style in http://editor.citationstyles.org/visualEditor/, however was not successful. The problem is that some references show up in the parentheticals as (First name middle initial last name et al., year), although they should show up as (Last name et al., year). There is no such example citation/bibliography in the editor, only one with a parenthetical citation in the form (Campbell and Pedersen, 2007).

    The style is generally correct, the change I would need is all first names to be omitted from parentheticals, and all first names to be abbreviated in the reference list.

    I also tried editing the code at all places where "first" is mentioned, but do not know how exactly to to do it. By intuition I deleted the numbers in quotation marks in all cases where "use-first" was followed by a number (lines 158, 173, 175, 177, 178), but this resulted in a parenthetical listing all authors instead of only the first author followed by et al. and year.

    Could someone please show me what to change?

    Thank you in advance.
  • edited April 6, 2018
    You are likely seeing this:
    https://www.zotero.org/support/kb/given_name_disambiguation

    That would likely be an issue with your Zotero data (same author entered some places as initials, some places with the full given name), not an issue with your style.
  • Hey guys,
    I face similar problem, and since I'm total programming moron, I have no idea how to solve it.
    I quote some internet articles in my thesis and I'd like to change the way how the access date is presented in document. Now it looks like "[12 January 2019]", while I'd prefer something like "(access: 12.01.2019)". I looked at it with Zotero style editor, but this is totally double Dutch to me. Could someone help me with this issue?
    I use specific Polish legal style that I generally like, it's just this one thing that looks bad.
  • Hi Larry, I recommend using the Visual CSL Editor for quick fixes to styles without touching code: https://editor.citationstyles.org/visualEditor/. You can load your style file there, and look at the sample data (if you need more, you can also select different data or even add your own reference in (see the Example citations link). You can then click on the access date, which will open up the code that is formatting the date. You can use the dialog boxes to change the format of the date, and then you save the file again and update the style.
Sign In or Register to comment.