Improving the Layout

From the previous, it may already have become clear that the structure in the citation and bibliography fields can quickly get complicated. For this reason, CSL has a neat feature called macros that allows to group functionality together in an orderly fashion.
First the previous style sheet will be rewritten in order to bring the same functionality together in macros:
<?xml version="1.0" encoding="UTF-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl"
  class="in-text" xml:lang="en" default-locale="en-US">
  
  <info>
    <...>
  </info>
 
  <name="cite">
    <names variable="author">
      <name font-weight="normal">
    </names>
  </macro>
 
  <name="bibl">
    <names variable="author">
      <name font-weight="normal">
    </names>
    <text variable="title">
  </macro>
 
  <citation>
    <option name="et-al-min" value="3" />
    <layout>
      <text macro="cite">
    </layout>
  </citation>
  
  <bibliography>
    <option name="et-al-min" value="4" />
    <layout prefix="(" suffix=")">
      <text macro="bibl"">
    </layout>
  </bibliography>
</style>

As you can see, the style information has been assembled in two macros, and in the citation and bibliography a simple call to the macors have been included. Ideally, all the required functionality and styling should be grouped in macros, while the citation and bibliography fields should remain as simple as possible; preferably just the optional settings and a list of calls to macros.
Another slight change has been made to the layout of the citation. By adding the prefix and suffix attributes, the citation will be in braces; e.g (Doe 1999).
With this, we can now start to make our style a bit more useful. First, as one may have seen running the validator, the et. al is still not functioning correctly. The 'et-al-min' attribute aims to inform the citation manager how many authors need to be included before et. al starts to work. However, another attribute called 'et-al-use-first' is required to actually activate et. al in a document.
Suppose for instance you select: 'et-al-min'=3, 'et-al-use-first'=1. As a result, an article that was written by three or more authors will give the following citation: (Smith et. al, 1993). If an article or book is written by two authors, you get (Smith, Jones 1993)
Another useful option is to show the year that a book or article is published, in both the citations as the bibliography.
One problem now arises, and that is that the authors, dates and so on are not separated with commas. This could theoretically be correct in the layout, with the delimiter attribute, but as we want to have a bit more control over the delimiters, we will use the groups field instead. A group can be used to collect a number of elements and apply a single formatting strategy.
In the example below, authors will be separated using a comma (,), but in the citation, the date is excluded.
Last, the title will be printed in italics in double quotes.
<?xml version="1.0" encoding="UTF-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl"
  class="in-text" xml:lang="en" default-locale="en-US">
  
  <info>
    <...>
  </info>
 
  <macro name="date">
    <date variable="issued">
      <date-part name="year">
    </date>
  </macro>
 
  <macro name="cite">
    <group delimiter=", ">
      <names variable="author">
        <name font-weight="normal">
      </names>
    </group>
    <text macro="date">
  </macro>
 
  <macro name="bibl">
    <group delimiter=", ">
      <names variable="author">
        <name font-weight="normal">
      </names>
      <text variable="title">
      <text macro="date" prefix=" (" suffix=")">
    </group>
  </macro>
 
  <citation>
    <option name="et-al-min" value="3" />
    <option name="et-al-first-use" value="1" />
    <layout prefix="(" suffix=")">
      <text macro="cite">
    </layout>
  </citation>
  
  <bibliography>
    <option name="et-al-min" value="3" />
    <option name="et-al-first-use" value="3" />
    <layout>
      <text macro="bibl"">
    </layout>
  </bibliography>
</style>

After validation, the resulting citation style can be tested by reloading the file with Firefox and then reloading the Zotero test pane. The result should look something like this:
  

Single Citations

(Diederik Aerts et al., 2005)

Multi Citations

(Diederik Aerts et al., 2005)

Bibliography

Diederik Aerts, Bart D'Hooghe, Nicole Note, (2005), Worldviews, Science and Us: Redemarcating Knowledge and Its Social and Ethical Implications


As may become clear in this example, the publication date has been assembled in a macro and has been used both in the citation as the bibliography.
Home Citation Style Sheet (test_B.csl)