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

3.4.  createTable(): Set up the XHTML table

This function sets up an empty XHTML table as a child of the doc node containing the XHTML document fragment. For the overall structure of the XHTML, see Section 2, “ Operation ”.

homelist.py
# - - -   c r e a t e T a b l e   - - -

def createTable ( doc ):
    """Create an empty table.

      [ doc is a DOM DocumentFragment node ->
          doc    :=  doc containing an empty XHTML table
          return that XHTML table as an Element node ]
    """
    #-- 1 --
    # [ doc     :=  doc with a table element added
    #   result  :=  that table element ]
    table  =  xc.Element ( doc, 'table', border='3', cellpadding='3' )

    #-- 2 --
    # [ table  :=  table with its heading row added ]
    headRow  =  xc.Element ( table, 'tr' )

    head1  =  xc.Element ( headRow, 'th' )
    xc.Text ( head1, 'User name' )

    head2  =  xc.Element ( headRow, 'th' )
    xc.Text ( head2, 'Homepage' )

    #-- 3 --
    return table