DOC PREVIEW
CMU ISM 95702 - Homework

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

95-702 Organizational Communication & Distributed Object Technologies Carnegie Mellon UniversityLab 2 Due: Exam 1 Day - Wednesday, February 18, 2004The Web For Programs95-702 Organizational Communication & Distributed Object Technologies Carnegie Mellon University Lab 2 Due: Exam 1 Day - Wednesday, February 18, 2004The Web For Programs This is a two part homework problem. In the first part you will work with an XML parser and the Document ObjectModel (DOM) to write a client application that visits web sites and schedules meetings. In the second part you willwrite a web application that uses the SimpleAPI for XML (SAX) to collect data from RSS news feeds.Before beginning, make sure that your classpath contains a “.” and pointers to xercesImpl.jar and dom.jar. Thesefiles will be found under you JWSDP directory.Part IAssume that following schedule (schedule.xml) and the following Document Type Definition are available on theinternet. In order to simplify the project we will assume that the letters A,B,C, and D represent well known timeslots.File: schedule.xml located at http://localhost:8080/MccarthysSchedule/schedule.xml<?xml version="1.0" encoding = "utf-8"?><!DOCTYPE Schedule SYSTEM "Schedule.dtd"><Schedule> <Monday> <openSlot>A</openSlot> <openSlot>B</openSlot> </Monday> <Tuesday> <openSlot>B</openSlot> <openSlot>C</openSlot> </Tuesday> <Wednesday> <openSlot>B</openSlot> <openSlot>C</openSlot> </Wednesday> <Thursday> <openSlot>A</openSlot> </Thursday> <Friday> <openSlot>A</openSlot> <openSlot>C</openSlot> </Friday> <Saturday> <openSlot>A</openSlot> <openSlot>C</openSlot> </Saturday> <Sunday><openSlot>A</openSlot> </Sunday></Schedule> Figure 2.1195-702 Organizational Communication & Distributed Object Technologies Carnegie Mellon University File: Schedule.dtd located at http://localhost:8080/MccarthysSchedule/Schedule.dtd<!ELEMENT Schedule (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)><!ELEMENT Monday (openSlot*)><!ELEMENT Tuesday (openSlot*)><!ELEMENT Wednesday (openSlot*)><!ELEMENT Thursday (openSlot*)><!ELEMENT Friday (openSlot*)><!ELEMENT Saturday (openSlot*)><!ELEMENT Sunday (openSlot*)><!ELEMENT openSlot (#PCDATA)> Figure 2.2Let’s also assume that the following schedule and DTD are available locally:File: schedule.xml located in the client’s directory <?xml version="1.0" encoding = "utf-8"?><!DOCTYPE Schedule SYSTEM "Schedule.dtd"><Schedule> <Monday> <openSlot>C</openSlot> <openSlot>D</openSlot> </Monday> <Tuesday> <openSlot>A</openSlot> <openSlot>D</openSlot> </Tuesday> <Wednesday> <openSlot>B</openSlot> <openSlot>C</openSlot> </Wednesday> <Thursday> <openSlot>B</openSlot> </Thursday> <Friday> <openSlot>B</openSlot> <openSlot>D</openSlot> </Friday> <Saturday> <openSlot>B</openSlot> <openSlot>D</openSlot> </Saturday> <Sunday><openSlot>A</openSlot> </Sunday></Schedule> Figure 2.3File: Schedule.dtd holds the grammar for schedules and is located in the client’s directory as well295-702 Organizational Communication & Distributed Object Technologies Carnegie Mellon University <!ELEMENT Schedule (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)><!ELEMENT Monday (openSlot*)><!ELEMENT Tuesday (openSlot*)><!ELEMENT Wednesday (openSlot*)><!ELEMENT Thursday (openSlot*)><!ELEMENT Friday (openSlot*)><!ELEMENT Saturday (openSlot*)><!ELEMENT Sunday (openSlot*)><!ELEMENT openSlot (#PCDATA)> Figure 2.4In addition, the client will need to make use of an XML document containing URL’s of schedules. This document and its DTD appear next:File: urlList.xml located in the client’s directory<?xml version="1.0" encoding = "utf-8"?><!DOCTYPE URLList SYSTEM "urlList.dtd"><URLList> <URL>schedule.xml</URL> <URL>http://localhost:8080/MccarthysSchedule/schedule.xml</URL></URLList> Figure 2.5File: urlList.dtd located in the client’s directory <!ELEMENT URLList (URL*)><!ELEMENT URL (#PCDATA)>Figure 2.6Consider a Java client that reads the list of URL’s contained in the urlList.xml file. The program then fetches the schedule documents at those URL’s and displays a list of meeting times. The output of my solution looks like the following:D:\McCarthy\www\95-733\examples\scheduleOnTheWeb\clientcode>java SchedulerProcessing 2 schedulesGot 2 schedulesAvailable meeting timesSchedule meeting for Wednesday at BSchedule meeting for Wednesday at CSchedule meeting for Sunday at A Figure 2.7There are two document types that we are working with in this lab. The first is the document type that contains schedule data. The second is the document type that contains a list of URL’s. Below is a wrapper class that reads the URL’s into a DOM tree and provides user classes with a simple interface to the URL’s. It will be your responsibility to write the code that handles the schedule document type. Your wrapper class should know nothing about the scheduling process. In other words, your wrapper class should only provide simple access to the XML document’s fields. In this way, there is a natural separation of concerns and other applications might make use of these classes.395-702 Organizational Communication & Distributed Object Technologies Carnegie Mellon University /** URLListDoc.java Wraps urlList.xml documents Provide an InputSource object to initialize the objects of this class. An InputSource object may be created with a StringReader containing an XML document, a String containing a file path or a URL. This class passes the InputSource object to the parser and the document is parsed. The document’s fields are then available to a client program. The individual URL strings are returned by calling public String getURL(int i). The integer i must be in the range 1 <= i <= getNumURLs(). public int getNumURLs() returns an int representing the number of URLs in InputSource. */import java.io.File;import java.io.ByteArrayOutputStream;import java.io.OutputStreamWriter;import java.io.PrintWriter;import org.w3c.dom.*;import javax.xml.parsers.DocumentBuilderFactory;import org.xml.sax.InputSource;import javax.xml.parsers.DocumentBuilder;import org.xml.sax.SAXException;import org.xml.sax.SAXParseException;public class URLListDoc{ public final static String ROOT = "URLList"; public final static String


View Full Document

CMU ISM 95702 - Homework

Documents in this Course
Lecture

Lecture

25 pages

Lecture

Lecture

21 pages

Lecture

Lecture

24 pages

Exam

Exam

11 pages

Homework

Homework

16 pages

Homework

Homework

38 pages

lecture

lecture

38 pages

review

review

7 pages

lecture

lecture

18 pages

review

review

8 pages

Chapter2

Chapter2

32 pages

Lecture 4

Lecture 4

47 pages

Lecture

Lecture

22 pages

Naming

Naming

26 pages

lecture

lecture

34 pages

lecture

lecture

42 pages

lecture

lecture

112 pages

Lecture

Lecture

33 pages

Axis

Axis

43 pages

lecture

lecture

32 pages

review

review

17 pages

Lecture

Lecture

53 pages

Lecture

Lecture

80 pages

Lab

Lab

14 pages

Load more
Download Homework
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?