Greenstone tutorial exercise

Back to wiki
Back to index
Prerequisite: A large collection of HTML files—Tudor
Devised for Greenstone version: 2.60
Modified for Greenstone version: 2.86|3.06

Formatting the HTML collection—Tudor

  1. Open up your tudor collection, go to the Format panel (by clicking on its tab) and select Format Features from the left-hand list. Select the browse format feature and inspect its long format statement.

    This displays something that looks like this:

    A discussion of question five from Tudor Quiz: Henry VIII
    (quizstuff.html)

    for a particular document whose Title metadata is A discussion of question five from Tudor Quiz: Henry VIII and whose Source metadata is quizstuff.html.

    This format appears in the titles list and also when you get down to individual documents in the subjects hierarchy. This is Greenstone's default format statement used in the browse format features.

Greenstone's default format statement is complex because it is designed to produce something reasonable under almost any conditions, and also because for practical reasons it needs to be backwards compatible with legacy collections.

  1. In the browse format feature, replace the default documentNode template shown on the left with the simpler version on the right. (The highlighted lines on the left are the ones that have been removed or modified.)

    Change:To:

    <gsf:template match="documentNode">
    <td valign="top">
    <gsf:link type="document">
    <gsf:icon type="document"/>
    </gsf:link>
    </td>
    <td valign="top">
    <gsf:link type="source">
    <gsf:choose-metadata>
    <gsf:metadata name="thumbicon"/>
    <gsf:metadata name="srcicon"/>
    </gsf:choose-metadata>
    </gsf:link>
    </td>
    <td valign="top">
    <gsf:link type="document">
    <!--
    Defined in the global format statement
    -->
    <xsl:call-template name="choose-title"/>
    <gsf:switch>
    <gsf:metadata name="Source"/>
    <gsf:when test="exists">
    <br/>
    <i>(<gsf:metadata name="Source"/>)</i>
    </gsf:when>
    </gsf:switch>
    </gsf:link>
    </td>
    </gsf:template>

    <gsf:template match="documentNode">
    <td valign="top">
    <gsf:link type="document">
    <gsf:icon type="document"/>
    </gsf:link>
    </td>








    <td valign="top">
    <gsf:link type="document">



    <gsf:metadata name="Title"/>



    <br/>
    <i>(<gsf:metadata name="Source"/>)</i>


    </gsf:link>
    </td>
    </gsf:template>


    Preview the result (you don't need to build the collection, because changes to format statements take effect when you press the Preview Collection button). Look at the titles list. It is just the same as before! Under most circumstances this far simpler format statement is entirely equivalent to Greenstone's more complex default.

  1. Since we edited the browse format feature, the same format statements are used for documents listed in the titles list classifier and under each of the bookshelf nodes in the subject hierarchy classifier. The Choose Feature menu can be used to restrict a format statement to a specific classifier and its nodes. We will override this format statement for the hierarchical subject classifier. In the Choose Feature menu, scroll down to the item that says

    CL2 Hierarchy -metadata dc.Subject and Keywords

    and select it. This is the format statement that affects the second classifier (i.e., "CL2"), which is a Hierarchy classifier based on dc.Subject and Keywords metadata.

    Click <Add Format> to add this format statement to the collection.

    Edit the HTML Format String box, replacing the documentNode template on the left with the one on the right. (The changes are mostly the same as before, but without reference to the Source document name.)

    Change:To:

    <gsf:template match="documentNode">
    <td valign="top">
    <gsf:link type="document">
    <gsf:icon type="document"/>
    </gsf:link>
    </td>
    <td valign="top">
    <gsf:link type="source">
    <gsf:choose-metadata>
    <gsf:metadata name="thumbicon"/>
    <gsf:metadata name="srcicon"/>
    </gsf:choose-metadata>
    </gsf:link>
    </td>
    <td valign="top">
    <gsf:link type="document">
    <!--
    Defined in the global format statement
    -->
    <xsl:call-template name="choose-title"/>
    <gsf:switch>
    <gsf:metadata name="Source"/>
    <gsf:when test="exists">
    <br/>
    <i>(<gsf:metadata name="Source"/>)</i>
    </gsf:when>
    </gsf:switch>
    </gsf:link>
    </td>
    </gsf:template>

    <gsf:template match="documentNode">
    <td valign="top">
    <gsf:link type="document">
    <gsf:icon type="document"/>
    </gsf:link>
    </td>








    <td valign="top">
    <gsf:link type="document">



    <gsf:metadata name="Title"/>







    </gsf:link>
    </td>
    </gsf:template>


  1. Preview the subjects list in the collection. When you get down to a list of documents in the subject hierarchy, the filename does not appear beside the title, because Source is not specified in the format statement and this format statement applies to all documentNodes in the subject classifier. Note that the titles classifier has not changed: it still displays the filename underneath the title.

  1. Let's change the search results' format statement so that dc.Subject and Keywords metadata is displayed below the title. Select the search format feature. Insert the highlighted line:

    <gsf:template match="documentNode">
    <td valign="top">
    <gsf:link type="document">
    <gsf:icon type="document"/>
    </gsf:link>
    </td>
    <td>
    <gsf:link type="document">
    <xsl:call-template name="choose-title"/>
    </gsf:link>
    <br /><gsf:metadata name="dc.Subject"/>
    </td>
    </gsf:template>

  1. Preview the collection. Documents in the search results list will be displayed like this:

    A discussion of question five from Tudor Quiz: Henry VIII
    Tudor period|Others
    (The vertical bar appears because this dc.Subject and Keywords metadata is hierarchical metadata. Unfortunately there is no easy way to get at individual components of the hierarchy. For most metadata, such as title and author, this isn't a problem.)

  1. Finally, let's return to the subjects hierarchy and modify the bookshelf display. Reselect the format feature for

    CL2 Hierarchy -metadata dc.Subject and Keywords

    First modify the documentNode template so that it now looks like:

    <gsf:template match="documentNode">
    <td valign="top">
    <gsf:link type="document">
    <gsf:icon type="document"/>
    </gsf:link>
    </td>
    <td valign="top">
    <b>Title:</b>
    <gsf:metadata name="Title"/>
    </td>
    </gsf:template>

    Next, scroll down to the VList classifierNode template, and add in the highlighted statement:

    <gsf:template match="classifierNode[@classifierStyle = 'VList']">
    <td valign="top">
    <gsf:link type="classifier">
    <gsf:icon type="classifier"/>
    </gsf:link>
    </td>
    <td valign="top">
    <b>Bookshelf title:</b><gsf:metadata name="Title"/>
    </td>
    </gsf:template>

    Preview the collection and examine the subject hierarchy again to see the effect of your changes. Bookshelves should now say Bookshelf title: and then the subject name (which is the "title" of the bookshelf), while documents will display Title: and the title.


Copyright © 2005-2012 by the New Zealand Digital Library Project at the University of Waikato, New Zealand
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”