DOC PREVIEW
CMU ISM 95733 - Homework

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 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 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Homework 1 Due Wednesday, May 26, 2004A Web Interface To XML Validation95-733 Internet Technologies Carnegie Mellon University Homework 1 Due Wednesday, May 26, 2004A Web Interface To XML Validation In this lab you will write a web interface for XML document validation. The result will be similar to the webapplication found on a Brown University web site: http://www.stg.brown.edu/service/xmlvalid. That applicationwas written a number of years ago and due to the advances in XML tools your problem will be a good deal simplerto solve than was theirs.The index.html fileThere will be exactly one HTML file in this application. It will be called index.html and will be placed under thedirectory ValidationApp/web. When your Tomcat site is accessed by a browser, the index.html file will requesteither a URL (from which your servlet application will fetch an XML document) or the text of an XML documentwith an imbedded DTD. If the XML document is fetched from a URL then the server that provides that documentmust also provide the DTD referenced within the document. In either case, your servlet will receive a documentand a DTD.The index.html document will contain HTML code that allows the user to click one of two buttons. These buttonsallow the user to select the input source of the XML document. You will need to work with the HTML form tag. Itis important that you use the HTTP POST method from both of these forms. So, your servlet will need todistinguish between the two forms. To do this, you are required to use hidden form fields. Feel free to consult anytext on HTML for help.Your HTML document need not contain Java script to validate the fields. We will assume that we have a friendlyuser and that they enter a correct URL and that they are able to copy and paste XML documents to the text areas onthe screen.The user, however, may present you with an invalid document. It’s important that your application reports on theseerrors and does not crash.The XMLHandler.java servletThere will be exactly one servlet in this application. It will be called XMLHandler.java and will process all datafrom the browser with a doPost method. The doPost method will use the getParameter method of the HTTP request object to determine if it should fetch thedocument from a URL or already has a copy of the document within the request. In either case, the servlet willbuild an InputSource object (see the course text, page 27, for more on the InputSource class). It will then create aJava object of class ValidateBean. ValidateBean will take the InputSource object, perform validation, and return aString object to the servlet. The servlet will embed this string in HTML and send it back to the browser. ValidateBean.java There will be one class that handles validation and it will be called ValidateBean.java. It is required thatValidateBean.java implements the org.xml.sax.ErrorHandler interface. It is also important that this class does notcrash when reading an invalid XML document. All of its error handling will be written so that a string is returnedto the XMLHandler servlet. ValidateBean.java will use JAXP to build a DOM tree and perform validation.195-733 Internet Technologies Carnegie Mellon University Test Cases Your solution will be tested against the following documents:http://www.andrew.cmu.edu/~mm6/fpml2.0/example_1.xml a valid documenthttp://www.andrew.cmu.edu/~mm6/fpml2.0/example_1A.xml an invalid documenthttp://www.andrew.cmu.edu/~mm6/fpml2.0/example_1B.xml another invalid documentIn the text box, your code will be tested against the following valid document:<?xml version="1.0" encoding="utf-8"?><!DOCTYPE department [<!ELEMENT department (employee)*><!ELEMENT employee (name, (email | url))><!ATTLIST employee id CDATA #REQUIRED><!ELEMENT name (#PCDATA)><!ELEMENT email (#PCDATA)><!ELEMENT url EMPTY><!ATTLIST url href CDATA #REQUIRED>]><department> <employee id="J.D"> <name>John Doe</name> <email>[email protected]</email> </employee> <employee id="B.S"> <name>Bob Smith</name> <email>[email protected]</email> </employee> <employee id="A.M"> <name>Alice Miller</name> <url href="http://www.foo.com/~amiller/"/> </employee></department>295-733 Internet Technologies Carnegie Mellon University And, in the text area, your code will be tested against the following invalid document:<?xml version="1.0" encoding="utf-8"?><!DOCTYPE department [<!ELEMENT department (employee)*><!ELEMENT employee (name, (email | url))><!ATTLIST employee id CDATA #REQUIRED><!ELEMENT name (#PCDATA)><!ELEMENT email (#PCDATA)><!ELEMENT url EMPTY><!ATTLIST url href CDATA #REQUIRED>]><department> <employee id="J.D"> <name>John Doe</name> <email>[email protected]</email> </employee> <employee id="B.S"> <name>Bob Smith</name> <email>[email protected]</email> </employee> <employee id="A.M"> <name>Alice Miller</name> <url href="http://www.foo.com/~amiller/"/> </department> 395-733 Internet Technologies Carnegie Mellon University Submission RequirementsIn order for the grading effort to go smoothly, you must submit your solution in the following format. The pointslisted are for format issues. That is, if the format is not correct the grader will be able to deduct these points fromyour score.1) A large envelope with your name, course, and assignment number on the front. (1 Point)2) Within the envelope, a printout of three files: index.html, XMLHandler.java, ValidateBean.java. (6Points)3) An otherwise blank floppy disk containing exactly two directories: src and web. (2 points)4) The src directory will contain ValidateBean.java and XMLHandler.java, (2 Points)5) The web directory will contain the index.html file and the WEB-INF subdirectory. (2 Points)6) The WEB-INF subdirectory will contain your web.xml file. (2 Points)The remaining 85 points will be distributed as follows:1) The index.html file contains two working forms, uses doPost for both and calls XMLHandler.java. (25Points)2) XMLHandler.java uses doPost for all of its work, fetches documents from anywhere on the web, isable to work with text being sent by the browser, is documented and calls ValidateBean to performparsing and validation. XMLHandler generates appropriate HTML as a response. (25 Points)3) ValidateBean.java is documented and


View Full Document

CMU ISM 95733 - Homework

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?