====== CSL 0.8.1 Syntax Overview ====== This page describes the syntax of version 0.8.1 of the [[http://citationstyles.org/|Citation Style Language]] (CSL), including information specific to Zotero. An additional source of documentation is the [[http://bitbucket.org/bdarcus/csl-schema/src/83f9cf9b53bd/csl.rnc|CSL 0.8.1 schema]], which is written in [[http://www.relaxng.org/compact-tutorial-20030326.html|RELAX NG Compact]] and can be used for [[/support/dev/creating_citation_styles#validation|style validation]]. Pointers on how CSL styles can be created, modified, validated, shared and installed in Zotero can be found [[dev/Citation Styles|here]], together with more background information about CSL. ====== CSL Style Structure ====== All CSL styles share the same basic structure: only five different XML elements can be nested directly in the ''style'' root element: ''info'', ''citation'', ''bibliography'', ''macro'' and ''terms''. The roles of each of these elements (described in more detail below) are: * ''info'': contains metadata describing the style (name of the style, authors of the style, etc) * ''citation'': describes how in-text citations should be formatted * ''bibliography'': describes how bibliographies should be formatted * ''macro'': allows for reuse of formatting instructions, allowing for more compact styles * ''terms'': allows for the modification of locale-specific strings (e.g. "edited by" can be changed in "ed. by") ===== Independent and Dependent Styles ===== Two main types of CSL styles exist: independent and dependent styles. An independent style contains a full style description, and includes at least the ''info'' and ''citation'' element. Unless it is a note-based style that lacks a bibliography, it also includes the ''bibliography'' element. The ''terms'' element and one or more ''macro'' elements are optional in independent styles. A dependent style, on the other hand, merely refers to an independent style, like an alias or shortcut. It only includes the info element. Dependent styles are used if multiple publications share a single style format. Each publication can thus have its own dependent style (with the info section describing the journal's metadata, e.g. the journal's name or ISSNs) with a corresponding entry in (for instance) the Zotero Style Repository, while only a single independent master style has to be maintained. Note that dependent styles cannot be used to indicate changes compared to the master style. If there is any difference in formatting between two styles, however small, two separate CSL styles have to be created. ===== Preamble ===== Before the style element, each CSL style should include the XML declaration element, specifying the version of XML used as well as the character encoding. The ''style'' element itself carries a number of arguments: * ''xmlns'': the namespace declaration that binds the elements in the style to the given namespace URI * ''class'': with two possible values, "in-text" or "note", this specifies whether the style is note-based or uses in-text citations coupled to a bibliography * ''xml:lang'' (optional): specifies the locale used for argument values within the style * ''default-locale'' (optional): sets the localization of the style output. The effect is currently limited to localization of preset strings (e.g. "edited by"), but plans exist to extend this to punctuation (French quotes, different punctuation around quotation marks in American and British English). N.B. Support for the default-locale argument has not yet been implemented in Zotero. Currently styles are solely localized according to the locale set in Firefox, which can be overruled with the [[/support/hidden_prefs#export_and_citation_settings|export.bibliographyLocale]] user preference. An example of a preamble is shown below. For most styles only the value of ''class'' and ''default-locale'' will differ.