CSL author counting

I am trying to edit a CSL document to do the following:
if there are only two authors, I want to use a comma delimiter. If there are three or more authors, I want to use a semicolon. (I'm not making this up, it's a real requirement for the journal "Language"). I know there is a way to sort based on number of authors:
<macro name="author-count">
<names variable="author">
<name form="count"/>
</names>
</macro>
<sort>
<key macro="author-count">
</sort>

However, I can't figure out how to get hold of this author-count information to use it in a <choose> block in my contributors macro. Here is what I have so far (lots of irrelevant bits excluded):
<macro name="contributors">
<names variable="author">
<choose>
<if> <!-- HOW DO I SPECIFY THIS "IF" CONDITION AS "NUMBER OF AUTHORS IS GREATER THAN 2"? -->
<name delimiter="; "/>
</if>
<else>
<name delimiter=", "/>
</else>
</choose>
</names>
</macro>
  • edited August 14, 2012
    It's not currently possible to test for the number of authors in a choose block.

    What effect are you after? (Edit: sorry, you were quite specific.)
  • You might be able to play tricks with et-al-min, et-al-use-first and cs:substitute. I have no idea whether that would work though.
  • I've played with this idea a little bit, and I don't think it will work, since it seems that <cs:substitute> only executes if its parent variable is empty... I can't figure out how et-al-min could fool it into thinking its parent was empty in order to stick in an alternative <name> element with different delimiters.

    For the record, the actual desired behavior is even more complicated than I first realized, because the semicolon delimiter should ONLY apply to the primary contributors of the work. In other words, citing an edited volume in its entirety should read:

    Doe, John; Mary Smith; Pat Jones; and Cornelius Petersen, (eds.). Some italicized book title. etc etc

    However, for articles/chapters in larger volumes, the journal wants semicolons between the authors and commas between the editors:

    Robertson, Chad; Ryan Boyle; and Doug Haffie. Some chapter title. Some italicized book title, ed. by John Doe, Mary Smith, Pat Jones, and Cornelius Petersen. etc etc

    I reckon I can make separate macros: one for cases where editors get substituted in as primary contributors (in the case of empty <name variable="author">) that uses semicolons, and a second macro for cases where editors are secondary contributors that uses comma delimiters. But this still doesn't solve the two-names-vs-three-or-more-names problem that started this thread.
  • yes, the second issue can easily be accommodated with two macros - that's actually not very unusual.

    The primary issue can't be done, though. This is so bizarre as a requirement that I do wonder whether we should bother to try to include an option that makes this possible, to be honest.
  • Although I would like to find a way to make it work, I can't say that I disagree with you, Adam. Maybe I'll try to convince the journal to revise their style guide...
  • edited June 15, 2013
    I had the same problem and this worked for me:
    CSL citation options allow to use conditions if a variable exists or not. You could update some rare fields in your citation database, like genre, and use the following macro:
    <macro name="authors-spec">
    <choose>
    <if variable="genre">
    <!-- 2 authors -->
    <text variable="author"/>
    <!--some code-->
    </if>
    </choose>
    </macro>
  • edited June 15, 2013
    The general approach works, but genre isn't all that rare - it's used for pretty much every report and thesis. Also, it doesn't exist for all item types, so you wouldn't be able to do this, e.g. for journal articles. If you want to use a field for this, use extra
Sign In or Register to comment.