Next / Previous / Contents / TCC Help System / NM Tech homepage

4. The generated XHTML

The term “page body” refers to the variable part of a web page. The top level of the page, down to the body element, is generated by the tccpage.2 module discussed in Section 3, “Overview of the internals”.

Here is the set of navigational links we will pass to the TCCPage() constructor:

4.1. XHTML for the index page

Here is the body content for the index page.

    <h1>John W. Shipman's field notes</h1>
    <p>
      Notes are grouped according to the reporting seasons for
      <cite>Audubon Field Notes</cite>.
    </p>
    <p>
      See
      <a href='conventions.html'>How to read Shipman's field notes</a>
      for notational conventions and the author's contact information.
    </p>
    ...index table...

The referenced conventions.html page is hand-built and outside the scope of this script.

Here is the wrapper for the index table. Its class='seasons' attribute links it to the stylesheet rule described in Section 5.3, “table.seasons.

    <table border='5' cellpadding='5' class='seasons' width='100%'>
      <colgroup align='right'/>
      <colgroup span='12' align='left' width='*'/>
      <thead>
        <tr class='year-row'>
          <th>Year</th>
          <th class='winter' colspan='2'>Winter</th>
          <th class='spring' colspan='3'>Spring</th>
          <th class='summer' colspan='2'>Summer</th>
          <th class='fall' colspan='4'>Fall</th>
          <th class='winter'>Winter</th>
        </tr>
      </thead>
      <tbody>
        ...rows for years here...
      </tbody>
    </table>

The columns of the table are color-coded by season, and the winter season occurs both at the beginning and ending of the year. The months are assigned to seasons by the reporting requirements of Audubon Field Notes: winter is December–February; spring is March–May; summer is June–July; and fall is August–November The color-coding is handled by CSS rules; see Section 5.4, “Seasonal column markup rules: th.winter, etc.”.

Here is the XHTML for a table row for the year 1990. This illustrates the treatment of months that have no data. The class='year-group' attribute appears periodically on the tr element to add a heavier ruled line under the row (other tr elements have class='year-row'). This is a very important user-friendliness feature: without a bold line under a row every so often, and the color-coded columns, the reader's eye can get lost in the grid. The frequency of the year-group attribute is given by Section 10.11, “YEAR_GROUP_FREQUENCY. For the style markup of table rows, see Section 5.5, “CSS rules for rows of the index table”.

        <tr class='year-group'>
          <th class='row-label'>1990</th>
          <td class='winter'><a href='1990/1990-01.html'>January</a></td>
          <td class='winter'>&nbsp;</td>
          <td class='spring'><a href='1990/1990-03.html'>March</a></td>
          <td class='spring'>&nbsp;</td>
          <td class='spring'><a href='1990/1990-05.html'>May</a></td>
          <td class='summer'>&nbsp;</td>
          <td class='summer'>&nbsp;</td>
          <td class='fall'>&nbsp;</td>
          <td class='fall'>&nbsp;</td>
          <td class='fall'>&nbsp;</td>
          <td class='fall'><a href='1990/1990-11.html'>November</a></td>
          <td class='winter'>&nbsp;</td>
        </tr>

The year number is in a th element styled by a CSS rule described in Section 5.6, “th.row-label: The row label”. The table cells are in the usual td element, marked up with one of the seasonal style rules discussed in Section 5.4, “Seasonal column markup rules: th.winter, etc.”. Each cell contains a link to the month file if there is one, or a non-breaking space &nbsp; placeholder if there is no corresponding month page.

4.2. XHTML for the month page

The page's title is “Shipman's field notes, monthname yyyy”.

The overall page structure has these parts:

  • An h1 heading with a repeat of the page title, followed by a brief introductory paragraph.

        <h1>Shipman's field notes, September 2007</h1>
        <p>
          <a href='http://www.nmt.edu/~shipman/aba/conventions.html'
          >How to read Shipman's field notes</a>
        </p>
        <ul>
          ...page TOC...
        </ul>
        <hr/>
        ...first day-notes...
        <hr/>
        ...second day-notes...
        etc.
    
    
  • The page TOC (table of contents) has links to each daily section, and also lists the notable records for each day.

  • Each day-notes element from the source XML file is preceded by a horizontal rule (hr). The anchor name for each day's notes is the date in the form “Dyyyy-mm-dd ”.

    The schema allows more than one day-notes element for the same day. In this case, the anchor for the second and succeeding elements will have the same form except that letters will be appended, e.g., “D2005-05-16a”, “D2005-05-16b”, and so forth.

The page table of contents consists of a sequence of li (list item) elements, one for each day-notes element in the input file.

Each entry in the page TOC starts with a simple link to the anchor for that day-notes element. If there were any notable birds inside that element, the entry is followed by a div containing the names of the notable birds. Here is an example:

      <li>
        <a href='#D2007-09-30'>NM: 2007-09-30: Bosque del Apache NWR</a>
        <div class='loc-child'>
          <span class='notable'>Notable:</span>
          Osprey, Solitary Sandpiper, Sabine's Gull, Common Tern
        </div>
      </li>

The notable block is formatted by a CSS rule discussed in Section 5.7, “div.loc-child: Indented child block”. For styling of the label “Notable:”, see Section 5.2, “Inline markup rules”.

4.3. XHTML for one day-notes

Here is an outline of the XHTML generated for one day-notes element.

4.4. XHTML for the day-summary block

The daily summary block is wrapped in a “<div class='day-summary'>” element. It contains:

4.4.1. Historical note

In the output of the XSLT script that was the predecessor of noteweb the default locality code was displayed before the list of localities. For a discussion of why this no longer appears, see the remarks in the Section 23.12.1, “Historical note” accompanying Section 23.12, “MonthCell.__daySummary(): Render the daily summary block”. In any case, the output was:

  <div class='loc-child'>
    <span class='loc-label'>
      Default location: @code
    </span>
  </div>

where code is the default locality code for the day.

4.5. XHTML for locality definitions

For each defined locality code, this XHTML is generated:

      <div class='loc-def'>
        @code: name
        <div class='loc-narrative'>
          text
        </div>
        <div class='loc-narrative'>
          GPS: waypoint narrative
        </div>
        ...
      </div>

where code is the locality code and name is the name attribute of the locality. For the styling of the outer div, see Section 5.9, “div.loc-def: Location definition”.

The first inner div is generated only when there is a long description for the locality. If there are GPS waypoints defined for this locality, they follow inside the outer div. For the styling of these blocks, see Section 5.10, “div.loc-narrative: Locality narrative”.

4.6. XHTML for day-annotation elements

Still inside the daily summary block, here is the XHTML generated for elements in the day-annotation pattern: route, weather, missed, film, and any undifferentiated para elements or loose text children of the day-summary element.

      <div class='loc-child'>
        <span class='loc-label'>type:</span>
        text
      </div>

The span portion is omitted for undifferentiated text; otherwise it shows the content type such as “Film”.

The text may be a single paragraph, or it may be broken into multiple paragraphs. See Section 4.7, “XHTML rendering of narrative elements”.

If there are multiple paragraphs of narrative, each is in a separate div below the run-in label. However, if there is only one paragraph, that is a special case, and the content of that one paragraph is placed directly in the parent div.

4.7. XHTML rendering of narrative elements

An instance of the Narrative class from the birdnotes.py module is basically a container for one or more Paragraph instances.

A Paragraph instance, in turn, is a container for a sequence of text strings, each of which may or may not be marked up with either a genus or cite tag. The XHTML rendering of a Paragraph is:

        <div class='para'>
          text
        </div>

where text is a mixture of untagged text and text wrapped in span elements. For the styling of this block, see Section 5.11, “div.para: Ordinary paragraphs”.

Input text marked up with a genus tag is wrapped like this:

          <span class='genus'>...</span>

Text marked with cite will look like this:

          <span class='cite'>...</span>

4.8. XHTML for the form element

Each form element from the input file is rendered like this:

  1. A div element with class='form' wraps all generated content. For styling, see Section 5.12, “div.form: General form-related data”.

    Because the bird names of notable records are set in a red-bordered box, they need a little bit more vertical margin, so there is a variant rule for class='notable-form'.

  2. Display of the name or names of this form of bird. For the display of the bird name(s), see Section 4.9, “XHTML for bird form names”.

  3. If there is locality information attached to the If the input form element has loc-group or sighting-note content attached, it is rendered next. See Section 4.10, “XHTML rendering of form data”.

  4. If the form element has floc children, they are rendered next. See Section 4.13, “XHTML rendering of floc elements”.

4.9. XHTML for bird form names

Rendering of the bird name is driven by a BirdForm instance from birdnotes.py. This instance's .birdId attribute is an instance of class BirdId from the taxonomy module txny.py; it can represent single taxa, hybrids, or species pairs such as “Dusky/Hammond's Flycatcher.”

The entire name is wrapped in:

      <span class='bird-name'>...</span>

Inside this span are placed:

  1. The English name of the first or only form.

  2. If this is a compound form, the string ' x ' for hybrids or '/' for pair forms, followed by the English name of the second form.

  3. If the record is questionable, “?” is appended; if uncountable, “[uncountable]” is appended.

4.10. XHTML rendering of form data

Elements at two levels—form and floc—share the need to display two kinds of data that can be attached at either level: loc-group content and sighting-notes content. A third type of content, age-sex-group, can appear at either level in the XML input, but in the representation provided by the birdnotes.py module, it is always attached to the Sighting child of the BirdForm element.

The overall rendering of an input form element depends on whether it is the single-sighting or multi-sighting case:

  • In the single-sighting case, let us refer to that single sighting as S. There is only one div at the top level, and it looks schematically like this.

      <div class='form'>
        <span class='bird-name'>Greater Roadrunner</span>
        S.age-sex-group
        S.loc-group
        S.sighting-notes
      </div>
    

    where the loc-group and sighting-notes are rendered in separate div elements, but the age-sex-group follows the bird name on the same line.

    In this case, the loc-group may be inherited all or partially from the day-notes parent.

  • In the multiple-sighting case, here is a schematic of the rendering, where F is the form input element and S is a child sighting element.

      <div class='form'>
        <span class='bird-name'>Greater Roadrunner</span>
        F.loc-group
        F.sighting-notes
        <div class='floc'>
          S.age-sex-group
          S.loc-group
          S.sighting-notes
        </div>
        <div class='floc'>
          ...  
        </div>
        ...
      </div>
    

    In this case, the F.loc-group part appears only if there is an explicit .locGroup attribute on F. There is no point in using the inherited value, since the inherited parts will be displayed in the child sightings, combined with any explicit locality data in the children.

Here are some notes on the rendering of these various elements.

  • If there is a count in the age-sex-group, it is copied to the XHTML, followed by a space.

  • If there is an age code, it is copied directly, except that code “p” is converted to a Greek lowercase phi, φ, as entity reference “&#x03c6;”.

  • If there is a sex code, it is copied directly.

  • If the countability code is “?”, it is copied directly; countability code “-” is rendered as “[uncountable]”.

  • If the record is fide some other observer, that is rendered as “[<span class='genus'>fide</span> N]”, where N is the observer's name. Although the word fide is not technically a genus name, it falls under the same rule: italicize Latin words.

  • The locality-group, materialized as a LocGroup instance, generates both inline and block content.

    • There is always a locality code, explicit or inherited, and we translate that to the corresponding full name, preceded by an “@” sign.

    • If there is a GPS waypoint, we generate the inline text “GPS=...”.

    • If there is loc-detail content, it is rendered in a separate div with class='loc-child'. For the associated CSS rule, see Section 5.7, “div.loc-child: Indented child block”.

  • For the rendering of the various sighting-notes elements, see Section 4.11, “XHTML rendering of sighting notes”.

4.11. XHTML rendering of sighting notes

The elements of the sighting-notes content are rendered in this order:

  • If there is a description, it is packaged in a div class='loc-child'. The content is prefaced with the text “Description:”, with that text wrapped in a span class='loc-label'.

  • If there is a behavior block, it is packaged in a div like the previous case, except that the labeling text is “Behavior:”.

  • If there is a vocalization block, it is packaged like the previous cases, with the label “Vocalization:”.

  • If there are breeding notes, they are packaged the same way, with the label “Breeding:”.

  • There may be any number of photo links; these are rendered next. See Section 4.12, “XHTML rendering of photo links”.

  • General narrative follows. For its rendering, see Section 4.7, “XHTML rendering of narrative elements”.

4.12. XHTML rendering of photo links

Each photo link is rendered one of two ways, depending on whether there is a url attribute.

  • If there is a url:

            <a href='url'>
              <img src='/~shipman/thumb/catNo.jpg' alt='catNo'/>
            </a>
    

    where catNo is the photo's catalog number.

  • If there is no url, the catalog number is copied to the page, unadorned.

4.13. XHTML rendering of floc elements

Each input floc element is wrapped in an XHTML div element with class='floc'. For the associated style rule, see Section 5.13, “div.floc: Multiple sightings”.

The rendering of the sighting proceeds the same as described in Section 4.10, “XHTML rendering of form data”.