Trying to mod Chicago with sorted bibliography but style not recognised

I'm trying to modify the Chicago full note style with a sorted bibliography as per the instructions:

https://blogs.eui.eu/zotero/sort-a-bibliography-by-type.html
https://forums.zotero.org/discussion/23604/a-mini-guide-to-sort-bibliography-by-reference-type/
https://forums.zotero.org/discussion/39588/any-chance-of-grouping-bibliography-by-type-in-ms-word/

I downloaded the Chicago full note style from the styles repository and edited it using Notepad. When I try to add the csl file to Zotero (standalone) it tells me it is not a valid style file and doesn't appear to add (it doesn't appear after a restart either).

The changes I made were:

Changed opening part:
<title>Chicago Manual of Style 16th edition (full note with modded bibliography)</title>
<id>http://www.zotero.org/styles/chicago-fullnote-moddedbibliography</id>;

Added the sort macro:
<macro name="sort-key">
<choose>
<if type="book book chapter" match="any">
<text value="1"/>
</if>
<else-if type="article-journal article-magazine" match="any">
<text value="2"/>
</if>
<if type="document" match="any">
<text value="3">
</else-if>
<else>
<text value="4"/>
</else>
</choose>
</macro>

And finally added the sort command:
<key macro="sort-key"/>

I ran it through the CSL validator and it found 3 errors but none related to the things I changed. Strangely, if I run the unmoddified csl file through the validator it passes without problem. I'm sure I've made some stupid mistake here, can anyone help?
  • Can you copy/paste your modified version to https://gist.github.com/, create a public "gist", and give us the URL?
  • Although type="book book chapter" already clearly needs to be type="book chapter".
  • Thanks, Rintze. How would I have books and book chapters?

    Here is gist: https://gist.github.com/anonymous/f0fa1c50fa9bf683c90aa945dec43e91
  • You should all validation issue, but the problem is almost certainly this:
    <if type="document" match="any">
    <text value="3">
    </else-if>

    On the syntax level, this needs to be else-if in the first line. But also, this won't work, as there is no CSL type "document" (nor is there any other way to check for the "Document" item type in Zotero -- except to exclude all others -- which is why we generally discourage its use.
  • The CSL item type for book chapters is "chapter".

    Try


    <macro name="sort-key">
    <choose>
    <if type="book chapter" match="any">
    <text value="1" />
    </if>
    <else-if type="article-journal article-magazine" match="any">
    <text value="2" />
    </else-if>
    <else>
    <text value="3" />
    </else>
    </choose>
    </macro>


    (and @adamsmith probably meant to write "You should fix all validation issues")

    In general, use http://validator.citationstyles.org/ to make sure your style validates, if you're aren't using that website already.
  • Thanks, Rintze, Adam.
    I've redone the style following the instructions exactly and that seems to work (well it works on my Windows machine with Word which is where I created and edit the document but not my Mac at home). I'm now going to customise the macro using the item types I need which are listed here: http://aurimasv.github.io/z2csl/typeMap.xml

    I think this has been asked before but I just want to double check that it is impossible to sort by second variable, i.e. this is a historical study it would be excellent to assign, for example, all the primary documents with 'primary' in the Extra field and then 'secondary' for the secondary documents, and then have the bibliography in essentially two sections: primary works and secondary works.
  • I'm not 100% sure I understand the question, but you can sort by as many variables/macros as you want. E.g. if the <sort> section starts with
    <key variable="note"/>, then putting primary and secondary into the extra field with display primary sources first, then secondary sources. Any key macros or variables after that (e.g. sort-key) will sort within those two groups.

    What you can't do is _test_ for the content of a variable. i.e. something like
    <if note="primary">
    <text value="1" />
    </if> is invalid and won't work.
Sign In or Register to comment.