Citation Style Language

Revision as of 21:58, 4 May 2010 by 119.82.183.48 (Talk) (Getting started)

Revision as of 21:58, 4 May 2010 by 119.82.183.48 (Talk) (Getting started)

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 CSL 1.0 specification was published in March 2010.

The idea behind CSL

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 bibliographic data and a citation styles that can be used to create nicely formatted citations.

                           CSL-Style
                               |
                               v
 Bibliographic record -> CSL-Processor -> Citation

CSL-Processors are available in different programming languages. The most elaborate CSL-Processor is citeproc-js.

Getting started

If you use a reference management software such as Zotero you already use CSL under the hood. If you want to dig your hands into code, have a look at citeproc-js:

 hg clone http://bitbucket.org/fbennett/citeproc-js

Documentation is located in the manual directory or online at http://gsl-nagoya-u.net/http/pub/citeproc-doc.html and a demo that runs in a Browser is available at http://gsl-nagoya-u.net/http/pub/citeproc-demo/demo.html

Bibliographic record format

Of course you cannot throw any bibliographic record format into a CSL-Processor but you must use the field names defined in the CSL 1.0 specification. Some of the fields are repeatable and have an interal structure as described here. The CSL mappings used in the Zotero reference manager 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 a follows in incomplete Backus-Naur-Form and additional description:

A record is a JSON object with unique keys of three kinds (VAR, NAME, DATE, and TYPE):

(1) RECORD := '{' { STD ':' STD_VAL | NAME ':' NAME_VAL | DATE ':' DATE_VAL | TYPE }* '}' (plus comma as seperator)

A STD is a standard variable name as listed at http://citationstyles.org/downloads/specification.html#standard-variables.

(2) STD := '"abstract"' | '"annote"' | '"archive"' | ...

A NAME is a name variable name as listed at http://citationstyles.org/downloads/specification.html#name-variables.

(3) NAME := '"author"' | '"editor"' | ...

A DATE is a date variable name as listed at http://citationstyles.org/downloads/specification.html#date-variables.

(4) NAME := '"accessed"' | '"container"' | ...

A STD_VAL is simple JSON string

(5) STD_VAL := JSON_STRING (see JSON standard)

A TYPE contains a value from the types listed at http://citationstyles.org/downloads/specification.html#appendix-ii-types

(6) TYPE := '"type"' ':' ( '"article"' | '"book"' | ... )

A NAME_VAL is non-empty JSON array of JSON objects with NAME_PART keys and simple JSON string values:

(7) NAME_VAL := '[' ( '{' NAME_PART ':' JSON_STRING | STATIC_ORDERING '}' )+ ']' (plus comma as seperator)

A NAME_PART is variable name is one of

(8) NAME_PART := '"family"' | '"given"' | '"suffix"' | '"non-dropping-particle"' | '"dropping-particle"'

In addition you can add STATIC_ORDERING as part of the NAME_VAL to flag that a name is always displayed with the family name first ("non-Byzantine" names):

(9) STATIC_ORDERING := '"static-ordering"' ':' ANY_TRUE_JSON_VALUE (TODO: what is ANY_TRUE_JSON_VALUE?)

A DATE_VAL is a JSON object which contains at least a DATE_PARTS element and optionally a SEASON_VAL element:

(10) NAME_VAL := '{' '"date-parts"' ':' DATE_PARTS ( ',' '"season"' ':' SEASON_VAL )? '}'

A DATE_PARTS 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) DATE_PARTS := '[' DATE ( ',' DATE )? ']'
(11b) DATE  := '[' YEAR ( ',' MONTH ( ',' DAY )? )? ']'
(11c) YEAR  := JSON_STRING | JSON_INTEGER (string must contain an interger. Number must not be zero)
(11d) MONTH  := JSON_STRING | JSON_INTEGER (1 to 12)
(11e) DAY  := JSON_STRING | JSON_INTEGER (1 to 31)

A SEASON_VAL should be one of 1 to 4 or a fixed JSON string:

(12) SEASON_VAL := '"1"' | '"2"' | '"3"' | '"4"' | JSON_STRING

The 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.

A twitter annotation is a JSON object with up to 512 bytes (later more):

The CSL input format is also JSON but you need to specify a root element and how to deal with multiple references. This is how an annotation could look like:

  
{ "cslrecords" : {
    "ITEM-2" : {
	"author": [ {
			"family": "Bennett",
			"given": "Frank G.",
			"suffix": "Jr.",
			"static-ordering": false
	} ],
	"title":"Getting Property Right: \"Informal\" Mortgages in the Japanese Courts",
	"container-title":"Pacific Rim Law & Policy Journal",
	"volume": "18",
	"page": "463-509",
	"issued": { "date-parts": [ [2009, 8] ]	},
	"type": "article-journal"
     }
}

But you could also wrap the single records in a way to easily add more non-CSL data to it:

{ "bibrecords":
    "ITEM-2" : {
      "csl" : {
	"author": [ {
			"family": "Bennett",
			"given": "Frank G.",
			"suffix": "Jr.",
			"static-ordering": false
	} ],
	"title":"Getting Property Right: \"Informal\" Mortgages in the Japanese Courts",
	"container-title":"Pacific Rim Law & Policy Journal",
	"volume": "18",
	"page": "463-509",
	"issued": { "date-parts": [ [2009, 8] ]	},
	"type": "article-journal"
      },
      "identifier" [
         "urn:issn:1066-8632",
         "http://ssrn.com/abstract=1541102",
         "bibkey:18561d99b88967f176f0e4ab63d230c0e"
      ]
   }
}

References

Alternatives

  • http://www.refbase.net/ is open source and contains import filters and citation styles to create citations from bibliographic data

This page is licensed under CC-BA-SA and thus can be used on other pages such as Wikipedia as you like