/ ITC Help System
/ Site map
/ NM Tech homepage
DOM example: Web presentation
Given the existence of the previously discussed Python
the HTML presentation is written by a Python script named
Here are the command line options to this script:
addr-web [-u] infile.xml
||Show unlisted entries and phone numbers. Default is
to omit them.
||Name of the input file, valid according to address.dtd.
Design considerations for this script:
- Each <entry> element in the input file should be rendered
multiple locations---one for each <person> or <org>
element. To achieve this, we define a virtual class Block
that represents an arbitrary output block. Subclasses are
OrgBlock for an organization, PersonBlock for
a person, and XRefBlock for a cross-reference.
- The __cmp__() methods in these objects order the entries
into the desired output order. So, the main program goes through
the Entry objects, builds a list of Block objects from
them, and sorts the list.
- Once we have a sorted list of output blocks, we use the
.xhtml() methods of each block to generate its content.
The blocks will appear inside a large single table so we can
place the phone numbers in a narrow column on the left and the
rest of the stuff in a wide column on the right.
- We use the gen_xml.py module to build the HTML output.
(source for gen_xml.py)
Heavy use is made of Cascading Style Sheets to give the Web
rendering an attractive styling. Here is a list of the principle
rules in the
||The date/time stamp in the introductory paragraph.
|span.phone ||A phone number.
||The string used to alphabetize this block. For a person,
e.g., this will be 'Last[, First][ "Nick"]'.
||An <org> element other than the
||The <contact> element in an <org>, if any.
||A <person> element other than the
|span.loc ||A location (mail or street).
||The content from a <directions> element.
|span.notes ||The <notes> content if any.
See also: Document Object Model example: address book
Previous: DOM example: address book software design
to help pages
New Mexico Tech Information Technology and Communications: Help System
To report a problem: File a ticket
Send mail to the User consultant
on duty or call them at 575-835-5437
About New Mexico Tech
John Shipman, email@example.com
Last updated: 2002/11/07 00:48:41 UT