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
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?
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.)
@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>
Any comments? Would you prefer a pull request?