CSL. Zotero. Word Processor Plugins. Request group-by as child of bibliography element.

edited May 28, 2018
A feature request to add to the CSL schema a <group-by> element that would be a child of <bibliography>. That is, to facilitate Zotero's Word processor, and other, plugins to spit out a bibliography with items grouped under sub headings.

Document authors frequently wish to group items according to range of criteria. Often this is by Item Type. E.g. In listing Legislation before general items. But it could be by other criteria, e.g. works by a particular author before the rest.

If the <group-by> element could take a macro, as in `<group-by macro="my-group-by-macro" />` then the full flexibility of CSL macros would be available to a CSL author.

For example the simplest way to make this work might be to based it on the string returned, as in ...

<style>
 ...
 <macro name="my-group-by-macro">
  <choose>
   <if type="legislation">
    <text value="01 Legislation" />
   </if>
   <else-if type="legal_case">
    <text value="02 Cases" />
   </else-if>
   <else>
    <text value="03 General" />
   </else>
  </choose>
 </macro>
 <bibliography>
  <group-by macro="my-group-by-macro" />
  <sort>
   <key macro="contributors"/>
   <key macro="date" />
   <key macro="title" />
  </sort>
  <layout suffix=".">
  ...
  </layout>
 </bibliography>
</style>

The <sort> element would work as normal, to determine sorting within each group.

Sorting the groups themselves is done alphabetically. Because the CSL provided a number at the start of the string ... the groups sort straightforwardly.

A more sophisticated technique could return a pair: a group-by-sort-key; with a text value of the heading. E.g. So the CSL macro author could code something like

<macro name="my-group-by-macro">
 <choose>
  <if type="legislation">
   <text group-by-sort-key="01" value="Legislation" />
  </if>
  <else-if type="legal_case">
   <text group-by-sort-key="02" value="Cases" />
  </else-if>
  <else>
   <text group-by-sort-key="03" value="General" />
  </else>
 </choose>
</macro>

Edit: Reworded two awkward sentences. Cracked a paragraph in two.
  • This can already be accomplished by using <sort>. If you place your "group by" macro as the first key in <sort>, your bibliography will first be sorted (grouped) by this key, then sorted within each group by the other sort variables.
  • edited May 29, 2018
    Thanks bwiernik. Yes that is what I currently do: use a pseudo-group-by macro as the first key under <sort>.

    I also have a pseudo-group-by-tag macro as the first child under <layout>. So the output looks like (I output no tag for general items) ...

    Law - Statute. Crimes Act 1958 (VIC). 1958...
    Law - Statute. Trade Act of 2002, 19 USC Sec. 3803...
    Law - Case. Bush v. Schiavo, 885 So. 2d 321, (Fla. 2004). 2004. Florida.
    Law - Case. Quarmby v Keating [2009] TASSC 80. 2009. Suprem...
    Barker, Anne. 2016. "Full 01 Swiss ...
    Epictetus. [125AD] 1916. Enchiridion. Tran...
    Good of you to mention it in case I wasn't aware of it. But using that technique is less than ideal.

    By the way, have you (or anybody else) got a link to this forum's markup rules? I can't find anything on https://www.zotero.org/support/.

    Edit: Added pre tag after subsequent information about the use of html.
  • Forum mark-up is just basic filtered html, so you can use quote, blockquote, code, i, b, s, a href, etc. tags. (It's not ideal -- many of us would love markdown, but that doesn't appear to be easily possible)

    For your proposal, I think the goal is absolutely legitimate, but on the CSL side we've always maintained that this should be implemented as a feature of the reference manager (i.e. Zotero, Mendeley, etc.) as people will frequently want to group references by characteristics that are not accessible through CSL. This also gives people a lot more flexibility without having to edit citation styles (and there's no way we could even start to provide all requested versions of grouping for users).

    I don't think this is super close to happening for Zotero, though, I'm afraid.

  • Thanks adamsmith!

    On markup, thanks: I've got it. And I've seen that pre and h2 works. With blockquote (as you mention) those are probably the four main html tags of interest in a forum context. So that all looks fine even though I'd agree that markdown would be the ideal.

    On the proposal, your argument against it on the CSL side (and for it on the consuming processor side - reference managers) in terms of the available characteristics in CSL doesn't seem particularity convincing. For CSL macros seem enabled to spit out results on a wide ranges of characteristics. Thanks to the prior efforts of your good self, with many others, it doesn't appear that CSL is currently lacking in that regard (that it might not be able to spit out one or two characteristics that a user might desire doesn't seem significant).

    However, your argument against it on the CSL side (and for it on the consuming processor side) in terms of flexibility for the user I think can be made even more strongly (and you may well have the following in mind) ... That grouping bibliographic entries is going to be more of an ad hoc document author decision than a rule that a style author would be interested in making. For example it seems unlikely that the Chicago Manual of Style is going to (in any future) want to stipulate that, in all documents following the style, the grouping order should be: legislation, legal cases, general items (or any other order). And CSL really is for style conventions, not ad hoc conventions of a document author. In other words, the document author might want to follow the Chicago manual of style (and use the one CSL file) across all documents, but change the bibliographic grouping between documents. The flexibility argument is therefore convincing.

    So it does seem right that bibliographic grouping should be done at the consuming processor/reference manager side rather than the CSL side.

    Noting that Zotero is not likely to implement this soon, is there an existing issue for this in a repo somewhere? If not should we create one (as a low priority task)?



Sign In or Register to comment.