Programming XML in Java - Homework 2

Instructor: John Punin
CSCI 2962 Spring 2001
Due:  April 10th 11:59:59 PM

Objective

The objective of this homework is to help you become familiar with the SAX and DOM interfaces for XML parsers.

Description

The structure of a web site can be saved in a graph structure. The nodes of the graph represent the web pages and the edges of the graph represent the hyperlinks between the pages. XGMML is an XML application language to save graph structures. This is a simple example of an XGMML file that represents a graph with two nodes (web pages) and one edge (hyperlink) :
<?xml version="1.0"?>
<graph>
  <node id="1" label="http://www.example.org/" weight="2345">
    <att name="title" value="Example Main Page"/>
    <att name="mime" value="text/html"/>
    <att name="size" value="2345"/>
    <att name="date" value="Wed Jun  9 23:01:06 2000"/>
    <att name="code" value="200"/>
  </node>
  <node id="2" label="http://www.example.org/software/" weight="1234">
    <att name="title" value="Software Examples"/>
    <att name="mime" value="text/html"/>
    <att name="size" value="1234"/>
    <att name="date" value="Wed Sep  19 13:11:23 2000"/>
    <att name="code" value="200"/>
  </node>
  <edge label="Software" source="1" target="2"/>
</graph>
The only elements that you need to know for this homework are: graph, node, edge and att. Problem: Given a XGMML file and a positive integer L, generate an HTML file that contains a list of node labels of nodes that have a weight greater than the number L.

Part A

Write a SAX application that solves the given problem. For this problem you are required to use Xerces XML Parser.

Part B

Write a DOM application that solves the given problem. For this problem you are required to use Xerces XML Parser.

Additional Information

I will provide with an XGMML file called xmlj.gr . You should write two java files: SAXweight.java and DOMweight.java. Please write comments in your java code.

An example how to run your java application SAXweight:

> java SAXweight xmlj.gr 2000 list.html


Where xmlj.gr is the given XGMML file, 2000 is the given integer L and list.html the name of the HTML file output.

If you are interested in reading more about XGMML: http://www.cs.rpi.edu/~puninj/XGMML/


Submission procedure:

Send one email message to uffelg@cs.rpi.edu, with the subject line reading "XMLJ: HW # 2 submission". You can write a little message if you want and then should include the files AS ATTACHMENTS. If you have 2 files, then you should have 2 attachments in the email message. Just as long as each attachment contains only one file.
to Programming XML in Java Home Page