element inside ?

I have been trying to get chicago-author-date.csl to cope with unsigned articles and reviews, where the name of the newspaper or periodical needs to stand in place of the author (see CMoS 14.207 and 14.217).

Duplicating <macro name="title"> to, say, <macro name="noauthor_title">, and having the latter return the container-title in case the type is article-journal, article-magazine, or article-newspaper seems to work as expected.

Trying what seems to be a simpler solution, i.e., inserting a <choose> element into <substitute>, along the lines of<macro name="author">
<names variable="author">
<substitute>
<names variable="editor"/>
<choose>
<if type="article-journal article-magazine article-newspaper" match="any">
<text macro="container-title"/>
</if>
</choose>
<text macro="title"/>
</substitute>
</names>
</macro>
however, I got confusing results. Before I investigate further, my question: is it legitimate to use <choose> inside <substitute> in the first place?
  • edited June 30, 2014
    That should work, but I work wrap the cs:choose in a macro for readability.

    Whatever variables are actually rendered via cs:substitute will be suppressed in the remainder of the cite.

    (Edit: Also, your condition should trigger only when a container-title is present, and fall back to title otherwise. That would call for folding the attempt to render the title into the same condition.)
  • edited July 1, 2014
    @fbennett - Thank you for the hints. It seems the patch below works as expected now, for both Zotero and pandoc.

    @adamsmith - Would you care to have a look, and possibly update the official chicago-author-date.csl as well as other chicago styles?

    The complete patched csl file ("chicago-author-date-ADDED-substitute-title.csl") is at https://gist.github.com/anonymous/3c38d85a3862243d283b

    $ diff -u chicago-author-date.csl chicago-author-date-ADDED-substitute-title.csl
    --- chicago-author-date.csl 2014-05-23 03:53:00.000000000 +0100
    +++ chicago-author-date-ADDED-substitute-title.csl 2014-07-01 11:25:06.000000000 +0100
    @@ -95,6 +95,23 @@
    <name and="text" delimiter=", "/>
    </names>
    </macro>
    + <macro name="substitute-title">
    + <choose>
    + <if type="article-journal article-magazine article-newspaper review review-book" match="any">
    + <choose>
    + <if variable="container-title">
    + <text macro="container-title" />
    + </if>
    + <else>
    + <text macro="title" />
    + </else>
    + </choose>
    + </if>
    + <else>
    + <text macro="title" />
    + </else>
    + </choose>
    + </macro>
    <macro name="contributors">
    <group delimiter=". ">
    <names variable="author">
    @@ -103,7 +120,7 @@
    <substitute>
    <names variable="editor"/>
    <names variable="translator"/>
    - <text macro="title"/>
    + <text macro="substitute-title"/>
    </substitute>
    </names>
    <text macro="recipient"/>
    @@ -115,7 +132,7 @@
    <substitute>
    <names variable="editor"/>
    <names variable="translator"/>
    - <text macro="title"/>
    + <text macro="substitute-title"/>
    </substitute>
    </names>
    </macro>
  • In case this wasn't too clear: The above is a proposal to patch the official chicago-author-date.csl.

    Any comments? Would you prefer a pull request?
  • yes, pull request would be much easier, thanks.
  • Done for chicago-author-date.csl. - Since the rule from 14.207/14.217 applies to all Chicago styles, would you be interested in pull requests for the others, too?
  • generally yes, but let me look at the pull request first.
  • (I've posted a mea culpa to the pull request. As @aurimas pointed out there, folding everything into a single macro like I suggested was not necessary.)
Sign In or Register to comment.