Help editing CSL style

Hello all,

I am editing a style to create a format not listed on the Zotero Repository. I am a complete novice with this...

Here is my code:

<macro name="container">
<choose>
<if type="chapter paper-conference" match="any">
<text term="in" prefix=", " suffix=": "/>
<names variable="editor translator" delimiter=", " suffix=", ">
<name name-as-sort-order="all" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
<label form="short" text-case="capitalize-first" prefix=" (" suffix=")"/>
</names>
<group delimiter=", ">
<text variable="container-title" text-case="title"/>
<text variable="collection-title" text-case="title"/>
</group>
</if>
<else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
<group prefix=", " delimiter=", ">
<text variable="container-title"/>
<text variable="collection-title"/>
</group>
</else-if>
<else>
<group prefix=". " delimiter=", ">
<text variable="container-title" form="short"/>
<text variable="collection-title"/>
</group>
</else>
</choose>
</macro>
<macro name="author">
<names variable="author">
<name name-as-sort-order="all" and="text" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="contextual"/>
<label form="short" prefix=" (" suffix=")" text-case="capitalize-first"/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<text macro="title"/>
</substitute>
</names>
</macro>
<macro name="author-short">
<names variable="author">
<name form="short" and="text" delimiter=", " initialize-with=". "/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<choose>
<if type="bill book graphic legal_case legislation motion_picture report song" match="any">
<text variable="title" form="short" font-style="italic"/>
</if>
<else>
<text variable="title" form="short" quotes="true"/>
</else>
</choose>
</substitute>
</names>
</macro>
<macro name="access">
<choose>
<if variable="DOI">
<text variable="" prefix=""/>
</if>
<else-if type="webpage">
<group delimiter=" ">
<text value="URL"/>
<text variable="URL"/>
<group prefix="(" suffix=").">
<text term="accessed" suffix=" "/>
<date variable="accessed">
<date-part name="month" form="numeric" suffix="."/>
<date-part name="day" suffix="."/>
<date-part name="year" form="short"/>
</date>
</group>
</group>
</else-if>
</choose>
</macro>
<macro name="title">
<choose>
<if type="report thesis" match="any">
<text variable="title"/>
<group prefix=" (" suffix=")" delimiter=" ">
<text variable="genre"/>
<text variable="number" prefix="No. "/>
</group>
</if>
<else-if type="bill book graphic legal_case legislation motion_picture report song speech" match="any">
<text variable="title"/>
<text macro="edition" prefix=". "/>
</else-if>
<else-if type="webpage">
<text variable="title"/>
<text value="WWW Document" prefix=" [" suffix="]"/>
</else-if>
<else>
<text variable="title" text-case="sentence"/>
</else>
</choose>
</macro>
<macro name="publisher">
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</macro>
<macro name="event">
<choose>
<if variable="event">
<text term="presented at" text-case="capitalize-first" suffix=" "/>
<text variable="event"/>
</if>
</choose>
</macro>
<macro name="issued">
<choose>
<if variable="issued">
<date variable="issued">
<date-part name="year" />
</date>
</if>
<else>
<text term="no date" form="short"/>
</else>
</choose>
</macro>
<macro name="edition">
<group delimiter=" ">
<choose>
<if is-numeric="edition">
<number variable="edition" form="ordinal"/>
</if>
<else>
<text variable="edition" suffix="."/>
</else>
</choose>
<text value="ed"/>
</group>
</macro>
<macro name="locators">
<choose>
<if type="article-journal article-magazine article-newspaper" match="any">
<group prefix=" " delimiter=":">
<group>
<text variable="volume"/>
</group>
<text variable="page"/>
</group>
</if>
<else-if type="bill book graphic legal_case legislation motion_picture report song thesis" match="any">
<group delimiter=", " prefix=". ">
<text macro="event"/>
<text macro="publisher"/>
</group>
</else-if>
<else-if type="chapter paper-conference" match="any">
<group delimiter=", " prefix=". ">
<text macro="event"/>
<text macro="publisher"/>
<group>
<label variable="page" form="short" suffix=" "/>
<text variable="page"/>
</group>
</group>
</else-if>
<else-if type="patent">
<text variable="number" prefix=". "/>
</else-if>
</choose>
</macro>
<citation et-al-min="3" et-al-use-first="1" disambiguate-add-givenname="true" disambiguate-add-year-suffix="true" collapse="year" cite-group-delimiter=", ">
<sort>
<key macro="author"/>
<key macro="issued" sort="descending"/>
</sort>
<layout prefix="(" suffix=")" delimiter="; ">
<group delimiter=", ">
<text macro="author-short"/>
<text macro="issued"/>
<group delimiter=" ">
<label variable="locator" form="short"/>
<text variable="locator"/>
</group>
</group>
</layout>
</citation>
<bibliography hanging-indent="true" entry-spacing="0" line-spacing="1">
<sort>
<key macro="author"/>
<key macro="issued" sort="ascending"/>
</sort>
<layout>
<group suffix=".">
<text macro="author" suffix=","/>
<text macro="issued" prefix=" "/>
<group prefix=". ">
<text macro="title"/>
<text macro="container"/>
<text macro="locators"/>
</group>
</group>
<text macro="access" prefix=". "/>
</layout>
</bibliography>
</style>


Example:
Vollmer, E.R., Creamer, N., Reberg-Horton, C., and Hoyt, G., 2010. Evaluating cover crop mulches for no-till organic production of onions. HortScience 45:61–70.

Changes desired:
1. Move first name initial in front of last name in all but first author, like:
Vollmer, E.R., N. Creamer, C. Reberg-Horton, and G. Hoyt.
2. Get rid of comma after final author and before date issued (but retain a period)

Thanks in advance for your help.
  • 1. Change
    <macro name="author">
    <names variable="author">
    <name name-as-sort-order="all" and="text" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="contextual"/>

    to
    <macro name="author">
    <names variable="author">
    <name name-as-sort-order="first" and="text" sort-separator=", " initialize-with="." delimiter=", "/>

    (changing the all to first is the key part. The rest is cosmetic)

    2.
    change
    <text macro="author" suffix=","/>
    to
    <text macro="author"/>
  • Wow, thank you for such a quick response! It worked perfectly.
  • Another question came up, this time for Web Site:

    I want to make this:

    Kelling, K.A., S.M. Combs, and J.B. Peters. 2002. Sampling for plant analysis [WWW Document]. Univ. Wis.-Madison Dep. Soil Sci. Ext. Madison. URL https://uwlab.soils.wisc.edu/pubs/pa_sampling.pdf (accessed 2.4.15).

    look like this:

    Kelling, K.A., S.M. Combs, and J.B. Peters. 2002. Sampling for plant analysis. Univ. Wis.-Madison. Dep. Soil Sci. Ext., Madison. 4 Feb. 2015. <https://uwlab.soils.wisc.edu/pubs/pa_sampling.pdf>.

    FYI, I entered the following text into the website title field within Zotero: "University of Wisconsin-Madison. Department of Soil Science Extension, Madison"

    Here are the main differences:
    1. Get rid of [WWW Document]
    2. Retain the period after the first "Madison"
    3. Put date accessed before the URL, no parentheses or "accessed", and in day-month-year format, with months longer then 4 letters abbreviated.
    4. Get rid of "URL" and put url in "< >"

    This may be asking too much, but if you have suggestions, I'd appreciate it!

    Thank you.
  • 1. delete <text value="WWW Document" prefix=" [" suffix="]"/>
    2. That's in your Zotero data, you can't change that in the style.
    3&4 change
    <else-if type="webpage">
    <group delimiter=" ">
    <text value="URL"/>
    <text variable="URL"/>
    <group prefix="(" suffix=").">
    <text term="accessed" suffix=" "/>
    <date variable="accessed">
    <date-part name="month" form="numeric" suffix="."/>
    <date-part name="day" suffix="."/>
    <date-part name="year" form="short"/>
    </date>
    </group>
    </group>
    </else-if>

    to

    <else-if type="webpage">
    <group delimiter=". ">
    <date variable="accessed">
    <date-part name="day" suffix=" "/>
    <date-part name="month" form="short" suffix=" "/>
    <date-part name="year"/>
    </date>
    </group>
    <text variable="URL" prefix="&lt;" suffix="&gt;"/>
    </group>
    </else-if>
  • Hi adamsmith,

    First changed worked perfectly.

    With regards to the second question, I do have a period after Madison in Zotero, but it gets deleted when listed in the bibliography in Word. Does Zotero just not like periods within the "Website Title" field?

    The code for 3 & 4 results in this error:

    Error parsing style:
    Error: File is not valid XML

    Thanks for the help.
  • sorry, should have been

    <else-if type="webpage">
    <group delimiter=". ">
    <date variable="accessed">
    <date-part name="day" suffix=" "/>
    <date-part name="month" form="short" suffix=" "/>
    <date-part name="year"/>
    </date>
    <text variable="URL" prefix="<" suffix=">"/>
    </group>
    </else-if>

    The period -- it's because of the form="short" on container-title. Do you want stuff abbreviated automatically?
  • Hmm...still getting the same error. Here's what I have in that region of the code:

    <macro name="access">
    <choose>
    <if variable="DOI">
    <text variable="" prefix=""/>
    </if>
    <else-if type="webpage">
    <group delimiter=". ">
    <date variable="accessed">
    <date-part name="day" suffix=" "/>
    <date-part name="month" form="short" suffix=" "/>
    <date-part name="year"/>
    </date>
    <text variable="URL" prefix="<" suffix=">"/>
    </group>
    </else-if>
    </choose>
    </macro>


    Yes, I do want it to abbreviate stuff automatically. The problem is that the available fields in "Web Page" don't match the components that I need to include according to formatting standards for this journal...so I am makeshifting it by putting a lot of info into the Title field. I guess I'll just have to find a different workaround.
  • <text variable="" prefix=""/>
    that's not right, you'll want to delete that.

    And then make sure that you don't actually have < and > in the prefix/suffix. You'll need the escaped version I use above.

    You may want to consider another item type, such as a report
  • Once I figured out what "escaped" meant, I changed < and > to < and > and it worked.

    However, somehow my titles for both journal articles and web pages stopped getting shortened. I still see form="short" under container-title in at least one place, though:

    <macro name="container">
    <choose>
    <if type="chapter paper-conference" match="any">
    <text term="in" prefix=", " suffix=": "/>
    <names variable="editor translator" delimiter=", " suffix=", ">
    <name name-as-sort-order="all" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
    <label form="short" text-case="capitalize-first" prefix=" (" suffix=")"/>
    </names>
    <group delimiter=", ">
    <text variable="container-title" text-case="title"/>
    <text variable="collection-title" text-case="title"/>
    </group>
    </if>
    <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
    <group prefix=", " delimiter=", ">
    <text variable="container-title"/>
    <text variable="collection-title"/>
    </group>
    </else-if>
    <else>
    <group prefix=". " delimiter=", ">
    <text variable="container-title" form="short"/>
    <text variable="collection-title"/>
    </group>
    </else>
    </choose>
    </macro>
  • automatic abbreviation would only work in the word processor via add-on. Is that where you're looking?
  • Ah, nope. I was looking only in the Style Editor preview. It works in Word.
  • automatic abbreviation would only work in the word processor via add-on
    Is that intentional?
  • no, it very much isn't. Simon just never got around to implementing abbreviations otherwise.
Sign In or Register to comment.