project2 - CSE 335 Fall 2009 Project 2 1 Objectives 1....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 335 Fall 2009 Project 2 1 Objectives 1. Maintain and extend an existing class library. 2. Gain experience integrating third-party classes into your own project. 3. Exercise the Builder pattern. 2 Description In the previous assignment, you wrote a library of classes for representing documents in the Doc- ument Object Model (DOM) format, and printing them as XML files. You also developed a small program to demonstrate the library’s functionality. In this project, you will be extending that li- brary to create a more useful application, where users can search for a string in an XML document and have matches printed in context. Through doing so, you will see examples of how the Builder and Visitor patterns can enable the reuse of existing code. 2.1 Parsing XML documents are, aside from some syntactical rules, ordinary text files. In order to work with these files, your application will need some way to bring them into the DOM representation for which your classes were designed. We have created an XML parser class for this purpose, which you may download from ˜ cse335/F09/P2 . With this class, you can read an XML file from disk and have a DOM tree assembled, using your own DOM classes. Of course, your DOM classes are different from your classmates’, and very likely have differ- ent methods for putting the corresponding objects together. Therefore, it is impossible for us to write a single parser class that directly interacts with everybody’s existing libraries. Instead, the XML Parser class is designed to create the DOM tree via the Builder pattern. Included with the XML Parser class files is code for an abstract class named Builder . Our XML parser uses this uniform interface to create DOM objects as it reads through an XML document, thereby allowing it to work with any DOM implementation. For your application, you will need to write a concrete subclass of Builder that implements the abstract methods to work with your own DOM classes. There are detailed comments given in Builder.h that explain what each of the abstract methods should accomplish. As a general overview of how your concrete builder should work, however: Nodes are created and added to the DOM tree one-by-one. It is assumed that there is some, “parent,” Element , to which each new node should be added. The first Element added should be made the root of the tree, and the initial parent Element . 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
To control the shape of the tree, two methods are provided, called Ascend() and Descend() .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2009 for the course CSE 335 taught by Professor Kraemer during the Fall '08 term at Michigan State University.

Page1 / 6

project2 - CSE 335 Fall 2009 Project 2 1 Objectives 1....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online