This is an old revision of the document!


CSLスタイル編集の手引き

Zoteroで使用される Citation Style Language (CSL) スタイルのための、スタイル編集ソフトが(今のところ)存在しませんが、引用様式は手動で編集することが可能です。この手引で編集すべきスタイルの見つけ方、そのスタイルの編集、そして修正されたスタイルをZoteroにインストールするための基本的な手順をご紹介します。

1 - ふさわしい引用様式から手をつけましょう

Zotero 引用様式保管庫をまずご確認ください。既存のCSLスタイルを改善したい場合には、最新の版を編集するように念を押してください(保管庫はそれぞれの引用様式が最後に更新された日付を示しています)。新しいスタイルを作りたい場合は、保管庫のプレヴュー機能を利用してもっともよく似た既存のスタイルを見つけてください(“Show only unique styles”にチェックをすると重複した物を隠すことができます)。またZotero プレヴュー画面を使ってインストール済みのスタイルの出力引用様式をZoteroライブラリの中の実際の項目を用いながら比較することができます。

Important If you have ever used Zotero 2.0 or an earlier version on your computer, your Zotero data directory probably still contains styles in the CSL 0.8.1 format. While Zotero 2.1 and newer still supports this older format, it is strongly recommended to always start with an up-to-date style CSL 1.0 style from the Zotero Style Repository, or, if you want to make changes to a CSL 0.8.1 style not present in the style repository, to first update it to 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 or TextEdit on Mac OS X. 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>

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

Save the style with a “.csl” file extension, 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…”)).

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.