====== The Citation Style Language ======
All citation styles shipped with Zotero, and available in the [[http://www.zotero.org/styles|Zotero Style Repository]], are written in the [[http://xbiblio.sourceforge.net/csl/|Citation Style Language]] (CSL). CSL is a new XML-based open standard for configuring citation formatting, designed to be independent of any particular application, document format, or programming language. Questions and comments related to CSL can be directed to the [[http://sourceforge.net/mail/?group_id=117435|CSL project developer mailing list]].
====== Creating and modifying styles ======
CSL is a new language that is still under development. Until more user-friendly wizards are developed, styles can only be created or modified by using text editors. However, this is not as scary as it sounds. Users with a little HTML or XML experience might quickly find themselves at home with CSL. A step-by-step guide to making basic changes is [[/support/csl_simple_edits|here]].
For editing CSL styles in text editors, the most current source of documentation for CSL is the [[http://bitbucket.org/bdarcus/csl-schema/raw/83f9cf9b53bd/csl.rnc|CSL schema]] itself. The schema, written in RelaxNG compact, is commented and relatively easy to read. In addition, the Zotero website hosts a page discussing the [[CSL Syntax summary|CSL syntax]], and provides specifics on the implementation of CSL in Zotero.
When it comes to tools available to edit the XML-code of CSL styles, it must be noted that even very simple text editors can be used (e.g. Notepad), although dedicated XML-editors can have the strong advantage of real-time XML validation. In addition, each installation of Zotero ships with two tools which can be used in writing styles:
* The Zotero Reference Test pane. Available by entering "chrome://zotero/content/tools/csledit.xul" in the Firefox address bar, this tool provides instant processing of CSL styles, using items selected in the local copy of Zotero.
* The Zotero Preview pane. Available by entering "chrome://zotero/content/tools/cslpreview.xul" in the Firefox address bar, this tool generates citations for the items selected in the local copy of Zotero for all installed CSL styles.
===== XML Validation =====
After creating a new style, make sure it is [[http://en.wikipedia.org/wiki/XML#Correctness|correct]]. For this the style has to be [[http://en.wikipedia.org/wiki/XML#Well-formedness|well-formed]], and has to [[http://en.wikipedia.org/wiki/XML#Validity|validate]] against the [[http://bitbucket.org/bdarcus/csl-schema/raw/83f9cf9b53bd/csl.rnc|CSL schema]]. Producing correct CSL styles is paramount for obtaining the desired output style formatting. Some XML validation tools that support RELAX NG Compact schemas:
* [[http://www.oxygenxml.com/|oXygen XML Editor]]: real-time validating editor (commercial)
* [[http://www.thaiopensource.com/nxml-mode/|emacs nXML mode]]: real-time validating mode for Emacs (open source)
* [[http://www.davidashen.net/rnv.html|RNV]]: command-line utility (open source)
* [[http://www.thaiopensource.com/relaxng/jing.html|Jing]]: command-line utility (open source)
* [[http://validator.nu/|Validator.nu]]: online XML validator (open source). The CSL schema is at "http://bitbucket.org/bdarcus/csl-schema/raw/83f9cf9b53bd/csl.rnc". Note that the option "Be lax about HTTP Content-Type" usually has to be checked.
Alternatively, the RELAX NG Compact schema can be converted to RELAX NG XML syntax with the open source command-line utility [[http://www.thaiopensource.com/relaxng/trang.html|Trang]]. Note that although Trang also supports conversion to XML 1.0 DTDs and W3C XML Schema, the CSL schema cannot be expressed in these schema languages.
===== Importing and Removing CSL Files in Zotero =====
Once you have created a CSL style, save it as a text file with a .csl extension (on Windows, make sure that file extensions aren't [[http://www.fileinfo.net/help/windows-show-extensions.html|hidden]]). Then, in Firefox, import the style either via the program menu (File->"Open File...") or just drag-and-drop the file into an open browser window. In Zotero 2.0 styles can also be added via the [[preferences/advanced|Styles]] tab in the Zotero preferences panel. Zotero will also automatically offer to import CSL files served with the text/x-csl content type.
CSL styles can also be removed from Zotero. In the 1.0 branch of Zotero, this is limited to a total reset of all styles: go to the [[preferences/advanced|Advanced]] tab in the preferences panel of Zotero, and click "Reset Translators and Styles...". In Zotero 2.0 individual styles can be deleted: for this, go to the [[preferences/advanced|Styles]] tab in the preferences panel.
===== The Zotero Style Repository =====
If your custom style has general appeal, consider submitting it to the [[http://www.zotero.org/styles|Zotero Style Repository]] via [[http://subversion.tigris.org/|SVN]]. Additional instructions can be found at the bottom of the Style Repository page.