Programming XML in Java - Homework 2

Instructor: John Punin
CSCI 2965 Fall 2001
Due:  October 1st 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 an XGMML file and a string S, generate an HTML file that contains a list of node labels of nodes that contain S as a substring in the title attribute of the node. For example, the label of Node 1 is "http://www.example.org/" and the title attribute is "Example Main Page".

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 xmljf.gr . You should write two java files: SAXsearch.java and DOMsearch.java. Please write comments in your java code.

An example how to run your java application SAXsearch:

> java SAXsearch xmljf.gr "Main" list.html


Where xmljf.gr is the given XGMML file, "Main" is the given string 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 gamars@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. The minimum requirement is that your code compiles. If you cannot get it to work PLEASE come to Stephane's office hours BEFORE the due date.
to Programming XML in Java Home Page