How to put 4 different variables into one single parenthesis?
I am trying to write my first CSL style, the style of the European Journal of International Law. For the thesis item type, I need to put 4 different variables into one parenthesis: (LLM/PhD thesis on file at [name of the university, place]/available online at [URL]), that is to say the variables genre, publisher, publisher-place and URL. I know I have to use conditionals but how can I manage to get the parenthesis opened and closed at the right place? Do I have to have a conditional for each case, according to which variable is present or not, that would be about 15 conditionals?
A group is a bundle of citation elements for which you can specify a prefix, suffix, and delimiters. You would set the parentheses as affixes for the group, rather than for any individual element.
Second, for displaying elements within the parentheses, you generally don't need to test for the presence of the variable before displaying it. If the variable is missing, it simply won't print. In your case, you will only need one conditional to test for the presence of a URL. If there is a URL, you would use that format, whereas if there is not a URL you would use the University/Place format.
Something like this should work:
<group prefix="(" suffix=")" delimiter=" ">
<text variable="genre"/>
<choose>
<if variable="URL" match="any">
<text term="available at"/>
<text variable="URL"/>
</if>
<else>
<text term="available at"/>
<group delimiter=", ">
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
</else>
</choose>
</group>
The "available at" term defaults in English to the words "available at". You can redefine these at the beginning of the style if needed. However, currently that code will use the same phrasing for both physical and online theses. Generally, that should be fine for most journals (what really is the difference between saying "thesis available at" and "thesis on file at"?). If that's not acceptable, you can always render literal text instead (but this is discouraged because it makes style maintenance more challenging and prevents automatic localization.
https://zoteromusings.wordpress.com/2013/10/28/writing-csl-features-and-best-practices/