CIT 597 Assignment 4: Processing XML
with Java
Fall 2008, David Matuszek
Take the XML (and DTD) you created in the previous assignment. Write a program in Java to read in the XML (a) using DOM, and (b) using SAX, extract certain kinds of information from the XML, and present the results in tables in HTML or XHTML files.
Create a Java project named ProcessXML. In that project, create
a package named xmlProcessor. In that package, create at least
the following two classes, each with a main method (you may
have additional classes if you prefer).
processWithDOMJFileChooser to
select your XML file (from the previous assignment). It will then use
DOM to parse the file, find all the lectures and readings,
and create an HTML page containing a two-column table, similar to
this example.
processWithSAXJFileChooser to
select your XML file (from the previous assignment). It will then use
SAX to parse the file, find all the assignments along
with the dates they were assigned,
and create an HTML page containing a two-column table, similar to
this example.
In both cases, you should get the class name (CIT 597, etc.) from the XML file. You do not need to get the table headings from the XML--you know what they are going to be.
I created these example files manually, and only started each table (I
used a vertical ellipsis, "...",
to indicate that there is more that I left out). Your program should collect
all the data of the correct type.
Use CSS to make your results look a little better. (This isn't primarily a CSS assignment, so don't spend a lot of time on this part.) It is okay to use HTML tables instead of CSS positioning commands, since they are easier.
Remember the DRY principle. These programs can share some code, for example, methods for writing out HTML. Also, use the same CSS file for both the DOM output and the SAX output.