This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CSE 335 Fall 2009 Project 1 1 Objectives 1. Develop a reusable class library. 2. Exercise the Composite pattern and the Visitor pattern. 2 Description In this assignment, you will develop a library to store an instance of the Document Object Model (DOM) in memory. The DOM is a way of representing an HTML or XML document, designed to make it easy for programs to access the different parts of the document and to modify its contents. The general idea is to treat the document as a tree, made out of nodes . Each node may contain some of the document’s information, and/or may also contain other nodes. An example of an XML document and its corresponding DOM tree is shown in Figures 1 and 2. This assignment uses a simplified version of the Document Object Model as a way to illustrate the Composite and Visitor patterns, as defined in your textbook. You will create classes to represent a DOM tree using the Composite pattern. You then will use the Visitor pattern to make it easy to create new operations for your DOM tree, both now and as the semester goes on. You are required to implement the following DOM classes: Node The abstract, top-level class from which the other four DOM classes should inherit. This class should expose two attributes, both of type string : name The name associated with the given node. value The informational value of the node. Text A type of node that represents a string of text. The text string should be stored in the node’s value. The name of a Text node is meaningless, and may be left blank. Comment A type of node that represents a comment in an HTML or XML document. The com- ment string should be stored in the node’s value. The name can be left as an empty string. Element A type of node that can contain other nodes. This will be the composite class in your DOM library. Elements can contain an arbitrary number of child nodes, as well as an arbi- trary number of attributes. This means that your Element class will need to contain some data structure (e.g. a vector) that stores pointers to the set of child Node s, and another one for the set of Attr s. It will also need to have the necessary methods for accessing these child nodes and attributes, as well as for adding new nodes or attributes to the set. The name of an Element is used to identify what that Element represents within a docu- ment, and is important. The value is usually ignored, and should be left blank....
View Full 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.
- Fall '08