This function builds the index page's table
element, the col elements describing the
columns, the thead element labeling the
columns, and the tbody element that will
contain the yearly rows of the table.
# - - - i n d e x T a b l e F r a m e
def indexTableFrame ( parent ):
'''Build an empty table.
[ parent is an et.Element ->
parent +:= a new table element containing column
definitions, column headings, and an empty tbody
element
return that tbody element ]
'''
For an overview of the XHTML, see Section 4.1, “XHTML for the index page”.
#-- 1 --
# [ parent +:= a new table element with class=SEASONS_CLASS
# table := that element ]
table = et.SubElement ( parent, 'table', border='5',
cellpadding='5', width='100%' )
table.attrib['class'] = SEASONS_CLASS
#-- 2 --
# [ table +:= new col elements declaring the column
# properties ]
et.SubElement ( table, 'colgroup', align='right' )
et.SubElement ( table, 'colgroup', span='12', align='left',
width='*' )
#-- 3 --
# [ table +:= a thead element containing the column
# labels ]
thead = et.SubElement ( table, 'thead' )
headRow = et.SubElement ( thead, 'tr' )
headRow.attrib['class'] = YEAR_ROW_CLASS
headLabel = et.SubElement ( headRow, 'th' )
headLabel.text = 'Year'
winter1 = et.SubElement ( headRow, 'th', colspan='2' )
winter1.attrib['class'] = 'winter'
winter1.text = 'Winter'
spring = et.SubElement ( headRow, 'th', colspan='3' )
spring.attrib['class'] = 'spring'
spring.text = 'Spring'
summer = et.SubElement ( headRow, 'th', colspan='2' )
summer.attrib['class'] = 'summer'
summer.text = 'Summer'
fall = et.SubElement ( headRow, 'th', colspan='4' )
fall.attrib['class'] = 'fall'
fall.text = 'Fall'
winter2 = et.SubElement ( headRow, 'th' )
winter2.attrib['class'] = 'winter'
winter2.text = 'Winter'
#-- 4 --
# [ table +:= a tbody element
# tbody := that element ]
tbody = et.SubElement ( table, 'tbody' )
#-- 5 --
return tbody