Project 6
Using SAX and DOM

Due on Monday March 31 before midnight


Description

This project must be done individually. No copying is permitted. The goal of this project is to learn the SAX and DOM XML APIs.

Platform

You will do this project on your own PC/laptop. You may use a text editor to develop your Java programs but it would be easier if you just use Netbeans.

Here are some examples:

Documentation

The following web pages provide some tutorials. Use them as a reference only.

Project Requirements

  1. Write a Java function
     
    void toSAX ( Node x, PrintHandler h )
    
    that converts a DOM node x and its descendants into a SAX stream, which is fed into the SAX handler h. The PrintHandler, which extends the SAX DefaultHandler, has SAX event handlers to print the SAX stream (see page 18 of the slides on XML tools). Use this function to print an entire XML document.
  2. Write a SAX handler in Java that parses an XML document using a SAX parser, and constructs the DOM tree of the document. Then the resulting DOM tree from this handler should be printed to the output using a DOM printer. Hint: You can construct a DOM tree from a SAX stream using a stack of DOM nodes.
You don't have to handle element attributes. Put everything in one Java file. Your Java program should run against the file cs.xml (which must be in the same directory), and should not have any arguments.

What to Submit

Use the form below to submit your java files.


Submit this file:


Last modified: 03/24/08 by Leonidas Fegaras