Next / Previous / Contents / Shipman's homepage

Abstract

Describes a system for translating XML-based bird field notes to HTML.

This publication is available in Web form and also as a PDF document. Please forward any comments to john@nmt.edu.

Table of Contents

1. Introduction
2. Operation
3. Overview of the internals
4. The generated XHTML
4.1. XHTML for the index page
4.2. XHTML for the month page
4.3. XHTML for one day-notes
4.4. XHTML for the day-summary block
4.5. XHTML for locality definitions
4.6. XHTML for day-annotation elements
4.7. XHTML rendering of narrative elements
4.8. XHTML for the form element
4.9. XHTML for bird form names
4.10. XHTML rendering of form data
4.11. XHTML rendering of sighting notes
4.12. XHTML rendering of photo links
4.13. XHTML rendering of floc elements
5. The style sheet
5.1. General style
5.2. Inline markup rules
5.3. table.seasons
5.4. Seasonal column markup rules: th.winter, etc.
5.5. CSS rules for rows of the index table
5.6. th.row-label: The row label
5.7. div.loc-child: Indented child block
5.8. div.day-summary: Daily summary block
5.9. div.loc-def: Location definition
5.10. div.loc-narrative: Locality narrative
5.11. div.para: Ordinary paragraphs
5.12. div.form: General form-related data
5.13. div.floc: Multiple sightings
6. Design notes
6.1. Discarded approaches
7. Overall program flow
8. Prologue
9. Imported modules
10. Manifest constants
10.1. MONTH_NAME_MAP: Translate month numbers to month names
10.2. MONTH_SEASON_MAP: Define the season for each month
10.3. YEAR_PAT: Pattern for year numbers
10.4. YYYY_MM_XML_PAT: Month file name pattern
10.5. HTML_EXT: File extension for XHTML pages
10.6. INDEX_PAGE_NAME: Name of the index page
10.7. INDEX_PAGE_TITLE
10.8. HOME_PAGE_URL: Home page URL
10.9. CONVENTIONS_URL
10.10. SEASONS_CLASS: Class attribute for the table of seasons
10.11. YEAR_GROUP_FREQUENCY
10.12. YEAR_GROUP_CLASS: CSS class for years ending a year group
10.13. YEAR_ROW_CLASS
10.14. ROW_LABEL_CLASS
10.15. NBSP: Non-breaking space character
10.16. PHI: Greek letter ϕ
10.17. CSS_URL: Our stylesheet
10.18. ZDP_LOGO
10.19. ZDP_URL
10.20. LOC_CHILD_CLASS
10.21. NOTABLE_CLASS
10.22. DAY_SUMMARY_CLASS
10.23. LOC_DEF_CLASS
10.24. LOC_NARRATIVE_CLASS
10.25. LOC_LABEL_CLASS
10.26. PARA_CLASS
10.27. FORM_CLASS
10.28. NOTABLE_FORM_CLASS
10.29. BIRD_NAME_CLASS
10.30. FLOC_CLASS
10.31. GENUS_CLASS
11. main(): The main program
12. findYears: Locate year directories
13. buildIndex(): Build the index page
14. pageFrame: Set up navigation for the index page
15. indexBoilerplate: Fixed content for the index page
16. indexTable(): Build the table of monthly links
17. indexTableFrame(): Set up the table structure
18. buildRow(): Build one row of the index table
19. buildMonthCell(): Build one monthly cell in the index table
20. class YearCollection: The top-level data structure
20.1. YearCollection.__init__(): Constructor
20.2. YearCollection.addYear(): Add a year
20.3. YearCollection.__getitem__(): Return self[yyyy]
20.4. YearCollection.genYearsRev(): Generate years in reverse chronological order
20.5. YearCollection.neighbors(): Find previous and next month
20.6. YearCollection.__findPrev(): Find predecessor month
20.7. YearCollection.findNext(): Find successor month
21. class YearRow: Container for one year's records
21.1. YearRow.__init__(): Constructor
21.2. YearRow.__len__(): Number of contained months
21.3. YearRow.__getitem__(): Retrieve one month
21.4. YearRow.firstMonth(): Return the first month
21.5. YearRow.lastMonth(): Return the last month
21.6. YearRow.predecessor(): Find the previous month
21.7. YearRow.successor(): Find the following month
21.8. YearRow.readAllMonths(): Process input files for one year
21.9. YearRow.readOneMonth(): Read one monthly file
21.10. YearRow.writeMonthPages(): Generate monthly pages
22. class MonthCell: One table cell
22.1. MonthCell.__init__(): Constructor
22.2. MonthCell.fileName(): Path to the month's page
22.3. MonthCell.writePage(): Render as XHTML
22.4. MonthCell.__pageFrame(): Set up a basic page
22.5. MonthCell.__renderPage(): Add the notes content
22.6. MonthCell.__pageTOC(): Generate page table of contents
22.7. MonthCell.__dayTOC(): Month table of contents entry for one day
22.8. MonthCell.__notablesBlock(): Display any notable records
22.9. MonthCell.__span(): Add a span inline
22.10. MonthCell.__dayBlock(): Render one daily note set
22.11. MonthCell.__dayTitle(): Render the title for one daily block
22.12. MonthCell.__daySummary(): Render the daily summary block
22.13. MonthCell.__locDef(): Display a locality definition
22.14. MonthCell.__dayAnnotation(): Render day-annotation content
22.15. MonthCell.__annoBlock(): Annotation block with a label
22.16. MonthCell.__narrative(): Render a Narrative instance
22.17. MonthCell.__paragraph(): Render one paragraph
22.18. MonthCell.__paraContent(): Content of one paragraph
22.19. MonthCell.__birdForm(): Render one BirdForm
22.20. MonthCell.__singleSighting(): Single-sighting case
22.21. MonthCell.__multiSighting(): Multiple-sighting case
22.22. MonthCell.__locGroup(): Render a locality group
22.23. MonthCell.__sightNotes(): Render a sighting notes group
22.24. MonthCell.__photo(): Generate a photo reference or link
22.25. MonthCell.__floc(): Generate one of multiple sightings
22.26. MonthCell.__ageSexGroup(): Render age-sex-group content
22.27. MonthCell.monthName(): Translate a month key to a month name (static method)
23. Epilogue
24. Defects discovered
24.1. Syntax errors
24.2. Logic errors
24.3. Run-time type matching errors

1. Introduction

Once birdwatching field notes are encoded in the form described in A system for encoding bird field notes, the next link in the tool chain is described herein: rendering these notes into a Web structure.

The noteweb script expects to be run from a directory containing all the notes files in this form:

  • Each year's worth of notes resides in subdirectory yyyy/, where yyyy is the four-digit year.

  • Each month's worth of notes resides in a single file at path yyyy/yyyy-mm.xml, where mm is the two-digit, zero-padded month number in the range 01-12.

Assuming all the input files are valid, the noteweb script builds these files, also in and under the current directory:

  • A set of HTML files, one for each input .xml file, but named yyyy/yyyy-mm.html.

  • field.html, a thumb-index page with links to the monthly pages. This organized as a table, with the years in rows and the months in columns.