Greenstone tutorial exercise

Back to wiki
Back to index

Section tagging for HTML documents

  1. In a browser, take a look at the Greenstone demo collection. Browse to one of the documents. This collection is based on HTML files, but they appear structured in the collection. This is because these HTML files were tagged by hand into sections.

  1. Using a text editor (e.g. WordPad) open up one of the HTML files from the demo collection: Greenstone → collect → demo → import → fb33fe →fb33fe.htm. You will see some HTML comments which contain section information for Greenstone. They look like:

    <!--
    <Section>
      <Description>
        <Metadata name="Title">Farming snails 1: Learning about snails;
        Building a pen; Food and shelter plants</Metadata>
      </Description>
    -->

    <!--
    </Section>
    <Section>
      <Description>
        <Metadata name="Title">Dew and rain</Metadata>
      </Description>
    -->

    When Greenstone encounters a <Section> tag in one of these comments, it will start a new subsection of the document. This will be closed when a </Section> tag is encountered. Metadata can also be added for each section—in this case, Title metadata has been added for each section. In the browser, find the Farming snails 1 document in the demo collection (through the Titles A-Z browser). Look at its table of contents and compare it to the <Section> tags in the HTML document.

  1. Add a new Section into this document. For example, add a new subsection into the Introduction chapter. In the text editor, add the following just after the Section tag for the Introduction section:

    <!--
    <Section>
      <Description>
        <Metadata name="Title">Snails are good to eat.</Metadata>
      </Description>
    -->

    Then just before the next section tag (What do you need to start?), add the following:

    <!--
    </Section>
    -->

    The effect of these changes is to make a new subsection inside the Introduction chapter.

  1. Open the Greenstone demo collection in the Librarian Interface. In the Document Plugins section of the Design panel, note that HTMLPlug has the description_tags option set. This option is needed when Section tags are used in the source documents.

    The metadata_fields option is not valid when description_tags is set—all metadata is expected to be in the Section tags if they are being used.

  1. Build and preview the collection. Look at the Farming snails 1 document again and check that your new section has been added.