In general, there are two main phases to the program. In the first phase, we build up a DOM tree representation of the XML content we'll be writing to the output. The second phase just consists of writing that tree to the standard output stream as XML.
We use the DOM's DocumentFragment type, instead of a full Document, in order to avoid getting a spurious
<?xml ...?> processing
instruction at the start of the output.
# - - - - - m a i n - - - - - #-- 1 -- # [ doc := a new, empty DOM DocumentFragment ] doc = xc.DocumentFragment() #-- 2 -- # [ doc := doc containing an XHTML table with heading row # table := that XHTML table as an Element node ] table = createTable ( doc ) #-- 3 -- # [ table := table with XHTML rows added representing a list of # user names and homepage links for all users in the TCC's # LDAP server who have a homepage ] scanAccounts ( table ) #-- 4 -- # [ doc := doc with end annotation added ] addEpilogue ( doc ) #-- 5 -- # [ sys.stdout +:= doc represented as XHTML ] doc.write()