This is an old revision of the document!


Modifier les styles CSL - Guide pas-à-pas

L'éditeur visuel: "CSL Visual Editor"

Un éditeur visuel de style CSL a été développé (open-source, il est le fruit d'une collaboration entre la bibliothèque de l'Université Columbia et Mendeley). Il est disponible ici. Un guide sommaire d'utilisation est en création (en anglais) ici. Si vous avez toutefois des difficultés à modifier des styles avec l'éditeur visuel, vous pouvez demander de l'aide sur le forum Zotero. Vous pouvez rapporter les bogues ici - assurez-vous de rapporter des erreurs reproductibles par quiconque. (Par ailleurs, le tracker GitHub n'est pas le lieu où poser des questions.)

Modification manuelle des styles CSL

Dans un certain nombre de cas, il est plus rapide de modifier manuellement un style. Ce guide indique quels étapes suivre.

1 - Commencez par choisir le bon style

Commencez par jeter un œil au dépôt des styles Zotero. Si vous voulez améliorer un style existant, assurez-vous que vous avez la version la plus récente (le dépôt indique la date et l'heure auxquelles chaque style ont été mis à jour). Si vous voulez créer un nouveau style, trouvez le style qui est le plus proche de vos besoins en utilisant la fonction de prévisualisation (en passant la souris au-dessus du nom du style). La façon la plus simple d'identifier le style le plus proche est d'utiliser la fonction “Recherche par l'exemple” (search by Example) de l'éditeur visuel.

Important Si vous avez utilisé Zotero 2.0 ou une version antérieure sur votre ordinateur, votre répertoire de données Zotero contient probablement encore des styles au format CSL 0.8.1. Bien que Zotero 2.1 (et suivants) supporte encore ce vieux format, il est fortement recommandé de toujours commencer avec une version à jour d'un style CSL 1.0 du dépôt des styles Zotero ou, si vous voulez modifier un style CSL 0.8.1 non présent dans le dépôt, de commencer par le mettre à jour vers CSL 1.0.

2 - Edit the Style

Download the style you want to edit to your computer, and open it in a (plain) text editor like Notepad on Windows, TextEdit on Mac OS X (select “Make Plain Text” under “Format”), or gedit in Linux. Other options are Notepad++ for Windows, TextWrangler for Mac OS X, oXygen XML Editor, Emacs in nXML mode, and jEdit, which all support XML syntax highlighting (CSL is an XML-based language) and in some cases also real-time validation against the CSL schema.

Paste the style code into the Zotero Reference Test pane, so you instantly see the effect of code changes on the style output. If you make your edits directly in the test pane, save your edits often via your text editor, as changes in the test pane get easily lost.

See the documentation page of the CSL project website for information on making CSL changes (in particular, make sure to take a look at the CSL specification. Below we discuss a few common and simple style edits to get you started.

Examples Edits

Changing Punctuation

In this example, we want to display the publisher (“CSHL Press”) and the location of the publisher (“Cold Spring Harbor, NY”) in a bibliographic entry. While this can be achieved with the code

<text variable="publisher"/>
<text variable="publisher-place"/>

this would result in “CSHL PressCold Spring Harbor, NY”. Fortunately, we can add some punctuation with the prefix, suffix and delimiter attributes. Let's say we want to separate the publisher and publisher-place by a comma-space, and wrap the whole in parentheses, i.e. “(CSHL Press, Cold Spring Harbor, NY)”. This can be done with:

<group delimiter=", " prefix="(" suffix=")">
  <text variable="publisher"/>
  <text variable="publisher-place"/>
</group>

The advantage of use a group element is that whenever you have a publisher, but no publisher-place, you don't end up with incorrect punctuation: the output would become “(CSHL Press)”. If you would set the punctuation directly onto the text elements, e.g.

<text variable="publisher" prefix="("/>
<text variable="publisher-place" prefix=", " suffix=")"/>

you would lose the closing bracket, i.e. “(CSHL Press”.

Changing Et-al Abbreviation

There are two main settings for et-al abbreviation (e.g., rendering the names “Doe, Smith & Johnson” as “Doe et al.”). The minimum number of names that activates et-al abbreviation, and the number of names shown before “et al.”.

In CSL, these settings can appear on the style, citation, bibliography or names elements in the form of the et-al-min and et-al-use-first attributes (it is possible to have separate settings for items that have been cited previously by using the et-al-subsequent-min and et-al-subsequent-use-first attributes).

For example,

<citation et-al-min="3" et-al-use-first="1">
  ...
</citation>

will result in name lists like “Doe”, “Doe & Smith” and, if there are three or more names, “Doe et al.”. Try changing these numbers and observe the effect.

Changing Disambiguation

CSL offers multiple methods to disambiguate cites or names. For example, a style might normally render only the family name (e.g., “(Doe 1999, Doe 2002)”). If the authors are Jane Doe and Thomas Doe, these names can be disambiguated by adding initials or the full given names (e.g., “(J. Doe 1999, T. Doe 2002)”).

Disambiguation methods are selected on the citation element. For example, to disable given name disambiguation, delete the disambiguate-add-givenname attribute, e.g. change

<citation disambiguate-add-givenname="true">
  ...
</citation>

to

<citation>
  ...
</citation>

Change the Style Title and ID

Before installing your edited style, change the title and ID of your style if you don't want your modified style to overwrite the original style.

The style title and ID are stored within the <title/> and <id/> elements near the top of the style. For example,

<title>Harvard Reference format 1 (Author-Date)</title> 
<id>http://www.zotero.org/styles/harvard1</id>

can be changed to

<title>Harvard Style Modified</title>
<id>http://www.zotero.org/styles/harvard-modified</id>

The URLs that you put in as an ID do not have to exist, i.e. you can use a zotero.org/style/mystyle type ID even if the style will not be posted on the Zotero repository.

Validation

Before installing a modified style, always make sure it is valid XML and CSL by validating against the CSL schema.

3 - Install your Edited Style with Zotero

Zotero for Firefox

Save the style with a “.csl” file extension (you can generally do this by simply typing “.csl” after the name of your file) , and drag-and-drop the CSL style file onto an open Firefox browser window, and click the “Install” button (you can ignore the grey bar at the top of the window (“This XML style does not appear…”)).

Zotero Standalone

Save the style with a “.csl” file extension (you can generally do this by simply typing ”.csl” after the name of your file). Then, go to the "Cite" tab in the Zotero preferences. Click on the + sign below the list of installed styles. In the file selection dialogue that opens, navigate to the .csl file you just created and open it. This will install your new style.

4 - Sharing Styles

If you think that your modified style might be useful to other people, consider submitting it to the Zotero Style Repository.

Getting Help

If you get stuck at any point, try searching the Zotero forums, or, if that doesn't give an answer, post in the forum's styles section.