project1 - CSE 335 Fall 2009 Project 1 1 Objectives 1...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern