NOTE:
These slides have not been updated since 2003. They have been superseded by the book
Anders Møller and Michael Schwartzbach, February 2006 |
INTERACTIVE WEB SERVICES WITH JAVA |
XML genEvents(TreeSet t) { XML x = templateScheduleDay; String hour1 = ""; String minute1 = ""; String hour2 = ""; String minute2 = ""; XML y = templateScheduleBlock; Iterator i = t.iterator(); while (i.hasNext()) { Element e = (Element)i.next(); String h1 = e.getChild("start").getAttributeValue("hour"); String m1 = e.getChild("start").getAttributeValue("minute"); String h2 = e.getChild("stop").getAttributeValue("hour"); String m2 = e.getChild("stop").getAttributeValue("minute"); if (!h1.equals(hour1) || !m1.equals(minute1) || !h2.equals(hour2) || !m2.equals(minute2)) { if (!hour1.equals("")) x = x<[events = templateScheduleEvents<[start=genHM(hour1,minute1),stop=genHM(hour2,minute2),block=y]]; y = templateScheduleBlock; hour1 = h1; minute1 = m1; hour2 = h2; minute2 = m2; } if (e.getName().equals("talk")) y=y<[event=templateScheduleTalk<[ track=genColor(e.getChildText("track")), speakers=genEventSpeakers(e), title=e.getChildText("title"), extra=genExtra(e.getChildText("link"),e.getChildText("linktext")), room=genRoom(e.getChildText("room"))]]; else y=y<[event=templateScheduleBreak<[title=e.getChildText("title")]]; } if (!hour1.equals("")) x = x<[events = templateScheduleEvents<[start=genHM(hour1,minute1),stop=genHM(hour2,minute2),block=y]]; return x; } |
Notice that the code does not contain any mark-up tags, but only refers to template constants such as:
const XML templateScheduleEvents = [[ <tr> <td valign="middle" align="center" width="100"><[start]> - <[stop]> </td> <td valign="top"><[block]></td> </tr> <tr><td colspan="5"><hr></td></tr> <[events]> ]] |
COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |