====== Greenstone 3 Format Statements ======
Greenstone3 uses XSL to dynamically generate all of the pages in your library. This provides a way to present different content in a consistent way.
Format statements are a way to customize the look of a collection/library //without// using XSL. While it is possible to use format statements in any of the interface XSL files, this page will focus on using them in the **Format Features** section of the **Format** panel in the GLI.
Format statements must be written in well-formed XML. XML syntax is very similar to HTML. [[http://www.w3schools.com/xml/xml_syntax.asp|W3Schools]] provides a list of the basic XML syntax rules. The Format Features section automatically checks your XML and errors will appear in the **XML Validation** text box.
This page provides an overview of format statements. There is also a [[gs3_list_of_format_options|list of formatting elements]] that can go in format statements.
===== Format Features =====
In the Format panel of the GLI, there is a Format Features section. This is where you can customize how parts of your collection will appear. Any changes made in the GLI will only effect the current collection (though, you can copy formatting into future collections by basing them on another collection). There are different types of pages in your collection, and you can select which page or pages you want your format changes to effect. For example, if you want to modify how search results will appear, you would modify the **search** format feature. If you want to modify how documents will be listed in all of your browsing classifiers, you would modify the **browse** format feature. If you want to modify just how the first browsing classifier will appear, you can select that classifier from the **Choose Feature** dropdown menu and click the **Add Format** button. The individual classifier will then have its own personal format feature for you to edit. The following table shows the different format features available in the GLI.
^Format Feature^Description^
|''browse''|Format will effect all browsing classifier pages|
|''searchType''|This feature is unique. It determines which types of search will be available; plain must be in the list for the quick search box to appear in the interface|
|''search''|Format will effect all search and search result pages in the collection|
|''global''|Format will effect all pages in the collection|
|''display''|Format will effect the document display pages|
|''CL1'',''CL2'', etc.|Format will effect the specific classifier page; format templates here will override format in the ''browse'' feature|
//**SearchType** is a unique feature: it is simply a list of the types of search pages you want in your collection. It defaults to include all three possible types. You can remove any of them, though, if you remove the "plain" search, the quick search box will not appear in the interface. The SearchType feature is ignored for the rest of this page, as it does not deal with format statements.//
So, each feature effects certain (or, for the **global** feature, potentially all) pages in the collection. To make these changes, you can add or modify one or more **templates** to the feature.
===== Templates =====
{{:en:templates2.png?direct&500 |}}
**Templates** are the containers for format statements. Different templates effect different parts of the page. For example, some basic templates for browse pages include:
* **documentNode**: Determines the display for each document (outlined in blue)
* **classifierNode[@classifierStyle = 'VList']**: Determines the display for each hierarchical item (outlined in orange)
* **classifierNode[@classifierStyle = 'HList']**: Determines the display for each item in the horizontal partitions (outlined in green)
//A browsing classifier may not have a hierarchy and/or horizontal partitions, in which case these templates (VList and HList, respectively) will be ignored.//
A simple **documentNode** classifier might look like this (The result of this format statement on a basic list browsing classifier is shown below):
\\
{{ :en:simple-format.png?direct&200|}}
Notice the ''
This is a link to Google!
Everything in between the ''a'' tags (in this case, the text "This is a link to Google!") becomes a link to the website specified in the ''href'' attribute (in this case ''http://www.google.com'').
Greenstone link statements work in a similar way, except instead of specifying the exact URL to link to, you specify the //type// of page to link to: //document//, //source//, or //classifier//.
In a **documentNode** template, you will likely want to link to either the document's display page in Greenstone or the source document itself (or both):
A link with type 'document' links to the document's display page in Greenstone.
A link with NO type also links to the the document's display page in Greenstone.
A link with type 'source' links to the source document itself, e.g. PDF, Word, JPG, etc.
\\
In a **classifierNode** template, you will generally have a link to the classifierNode, so that the user can click the node to see the items it contains (in a VList for a hierarchical subject classifier, they may click a subject to see all of the documents that have that subject; in an HList for a title classifier, they may click on a letter to see all documents with a title beginning with that letter). This is the default HList template, which has a classifier link:
\\
The final link type is slightly different. If you have specified associated documents for any items in your collection (generally, associated documents will be the same document in a different format), you can also add a link for these in the **documentNode** template:
This is a link to an associated/equivalent document.
===== Icons =====
Greenstone format statements make it easy to quickly add in icons. ''gsf:icon'' statements link to a particular icon:
* ''
===== Document Metadata =====
Any metadata that has been extracted from or added to documents can be referenced in format statements using the ''gsf:metadata'' tag. Metadata is referred to by its element name. For example, if you have provided ''dc.Title'' metadata for your documents, ''
Untitled
In this example, Greenstone will first look for ''dc.Title'', then (if the document does not have a value for ''dc.Title'') for ''exp.Title'', then for ''ex.dc.Title'', and finally for the extracted ''Title''. The first (and only the first) of metadata field in the list that has a value will be displayed. If the document has no value for any of these fields, the word "Untitled" will be displayed.
==== Switch ====
The switch format statement allows you to display different things based on the presence or value of a certain metadata field for a given document.
Author:
No Author
\\
This example is testing whether or not there is a value for ''dc.Creator''. The document has one or more values for ''dc.Creator'', e.g. Dr. Seuss, "**Author:** Dr. Seuss" will be displayed. If the document does not have a value for ''dc.Creator'', "//No Author//" will appear.
You can also test the //value// of a certain document (this example first test whether ''dc.Format'' equals "Lyrics", then "Discography", and finally "Tablature", and does something different in each instance):
===== Iteration =====
Sometimes a document will have more than one value for a particular metadata element.
In this simple example, each dc.Subject is output in bold formatting.
In this example, we add in a separator too. Separator is still useful here as we don't want it output for the last value, which would happen if we put the semi colon in the body of the element.
To sort the values, add ''@sort='true' '' to the
===== Additional Resources =====
* The **[[en:user:gs3_list_of_format_options|list of format statements]]** can be a useful reference when writing up format statements in Greenstone.
* There are some **[[en:user:gs3_sample_interface_modifications|sample GS3 format statements]]** available.
* The templates in the GLI only effect very specific parts of the page. You may want to completely change large portions of how your Greenstone library looks. For more information on how to do this, check out the [[interfaces]] page.
* [[http://wiki.greenstone.org/wiki/images/7/71/Skins_Doc.pdf|Greenstone 3 Interface Transformations Library: Basic Documentation]] //Maxime Roüast//