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>
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>
What effect are you after? (Edit: sorry, you were quite specific.)
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.
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.
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>