Changes

Jump to: navigation, search

Citation Style Language

4,228 bytes added, 22:56, 28 December 2010
m
Reverted edits by 79.142.68.99 (Talk); changed back to last version by 119.82.183.48
The '''Citation Style Language''' (CSL) is an XML-Based stylesheet language for formatting of citations and bibliographies. It is used in reference management software such as [[Zotero]], [[Mendeley]], [[CiteProc]] and [[Pandoc]]. CSL was initiated by Bruce D’Arcus in the XBib project. The latest specification of the language, CSL 1.0 specification , was published in March 2010.
== The idea behind CSL ==
Citation output is generated using CSL in a way similar to XSLT processing. If you know [[BibTeX]] you can compare CSL with the BibTeX style file language BAFLL (BibTeX Anonymous Forth-Like). If you know XSL than you can compare it with XSLT. The basic idea is to seperate separate bibliographic data and a the citation styles style definition, so that can be used to create nicely formatted citationsin various styles can be generated from a single body of data.
CSL-Style
Bibliographic record -> CSL-Processor -> Citation
CLS-Processors are available CSL processors have been written in different a variety of programming languages. The most elaborated complete implementation of CSL-Processor 1.0 at present is the Javascript implementation, [http://bitbucket.org/fbennett/citeproc-js/wiki/Home citeproc-js], which runs in Firefox and other Gecko-based browsers, Google Chrome, Safari, IE6 and above, and in Rhino and spidermonkey/tracemonkey for server-side deployments.
== Getting started ==
If you use a reference management software such as Zotero or Mendeley, you already use CLS CSL under the hood. If you want to dig your hands into code, have a look at citeproc-js, which is currently undergoing integration in these two projects:
hg clone http://bitbucket.org/fbennett/citeproc-js
Documentation is located in the manual directory or online at A [http://gsl-nagoya-u.net/http/pub/citeproc-doc.html and a demo that runs in a Browser formatted version of the processor manual] is available at online, and a [http://gsl-nagoya-u.net/http/pub/citeproc-demo/demo.htmldemo that runs the processor in a browser] is also available. The citeproc-js source archive contains a large suite of test cases, and the test framework offers a lightweight platform for exploring the behavior of the processor.
== Bibliographic record format ==
Of course you cannot throw just any bibliographic record format into a CSL-Processor but processor; you must use the [http://citationstyles.org/downloads/specification.html#appendices field names defined in the CSL 1.0 specification]. Some Fields are of the three types: plain text, date fields are repeatable , and name fields. The latter two have an interal internal structure [http://gsl-nagoya-u.net/http/pub/citeproc-doc.html#data-input as described here]. As a guide to the field assignments for particular types of content, the CSL mappings used in the Zotero reference manager [http://gsl-nagoya-u.net/http/pub/csl-fields/index.html are described here]. === CSL record format === Derived from the CSL 1.0 specification and the citeproc-js documentation, a CSL record can be defined as follows, in incomplete Backus-Naur form, with supplementary descriptions: A record is a JSON object with unique keys of three kinds (VAR, NAME, DATE, and TYPE): '''(1)''' <tt>RECORD := '{' { STD ':' STD_VAL | NAME ':' NAME_VAL | DATE ':' DATE_VAL | TYPE }* '}'</tt> (plus comma as seperator) A <tt>STD</tt> is a standard variable name as listed at http://citationstyles.org/downloads/specification.html#standard-variables. '''(2)''' <tt>STD := '"abstract"' | '"annote"' | '"archive"' | ... </tt> A <tt>NAME</tt> is a name variable name as listed at http://citationstyles.org/downloads/specification.html#name-variables. '''(3)''' <tt>NAME := '"author"' | '"editor"' | ... </tt> A <tt>DATE</tt> is a date variable name as listed at http://citationstyles.org/downloads/specification.html#date-variables. '''(4)''' <tt>NAME := '"accessed"' | '"container"' | ... </tt> A <tt>STD_VAL</tt> is simple JSON string '''(5)''' <tt>STD_VAL := JSON_STRING</tt> (see JSON standard) A <tt>TYPE</tt> contains a value from the types listed at http://citationstyles.org/downloads/specification.html#appendix-ii-types '''(6)''' <tt>TYPE := '"type"' ':' ( '"article"' | '"book"' | ... )</tt> A <tt>NAME_VAL</tt> is non-empty JSON array of JSON objects with <tt>NAME_PART</tt> keys and simple JSON string values: '''(7)''' <tt>NAME_VAL := '[' ( '{' NAME_PART ':' JSON_STRING | STATIC_ORDERING '}' )+ ']'</tt> (plus comma as seperator) A <tt>NAME_PART</tt> is variable name is one of '''(8)''' <tt>NAME_PART := '"family"' | '"given"' | '"suffix"' | '"non-dropping-particle"' | '"dropping-particle"'</tt> In addition you can add <tt>STATIC_ORDERING</tt> as part of the <tt>NAME_VAL</tt> to flag that a name is always displayed with the family name first ("non-Byzantine" names): '''(9)''' <tt>STATIC_ORDERING := '"static-ordering"' ':' ANY_TRUE_JSON_VALUE</tt> (TODO: what is ANY_TRUE_JSON_VALUE?) A <tt>DATE_VAL</tt> is a JSON object which contains at least a <tt>DATE_PARTS</tt> element and optionally a <tt>SEASON_VAL</tt> element: '''(10)''' <tt>NAME_VAL := '{' '"date-parts"' ':' DATE_PARTS ( ',' '"season"' ':' SEASON_VAL )? '}'</tt> A <tt>DATE_PARTS</tt> is is a nested JSON array containing a start date and optional end date, each of which consists of a year, an optional month and an optional day, in that order if present. '''(11a)''' <tt>DATE_PARTS := '[' DATE ( ',' DATE )? ']'</tt> <br/>'''(11b)''' <tt>DATE := '[' YEAR ( ',' MONTH ( ',' DAY )? )? ']'</tt> <br/>'''(11c)''' <tt>YEAR := JSON_STRING | JSON_INTEGER</tt> (string must contain an interger. Number must not be zero)<br/>'''(11d)''' <tt>MONTH := JSON_STRING | JSON_INTEGER</tt> (1 to 12)<br/>'''(11e)''' <tt>DAY := JSON_STRING | JSON_INTEGER</tt> (1 to 31)<br/> A <tt>SEASON_VAL</tt> should be one of 1 to 4 or a fixed JSON string: '''(12)''' <tt>SEASON_VAL := '"1"' | '"2"' | '"3"' | '"4"' | JSON_STRING</tt> The [http://gsl-nagoya-u.net/http/pub/citeproc-doc.html#dirty-tricks dirty-tricks fields of citeproc-js] are ''not valid'' CSL. Please clean your input data before feeding it to a CSL processor if you want to get sane citations. === Other record formats ===
If you want to use some other format (BibTeX, RIS, MARC, MODS, Bibliographic Ontology etc.) you go this way:
Record in your format -> some miracle occurs -> record in CSL format -> CSL-Processor -> Citation
Please replace "some miracle occurs" with the conversion service of your choice, for instance Zotero or some library software hacks that libraries tend to use. There is nothing wrong with specific bibliographic formats but its not their purpose to create citations (counterexamples: BibTeX and RIS).
== Embedding CSL records in twitter annotations ==
On the Code4lib mailing list it has been discussed to embed bibliographic data in twitter annotations. If this annotations contain CSL records then you could display a bibliographic reference in the citation style of your choice, delegating the formatting task to the client application.
A twitter annotation is a JSON object with up to 512 bytes (later more):

Navigation menu