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 September 13, 2004A Web Interface To XML Validation95-733 Internet Technologies Carnegie Mellon University Homework 1 Due September 13, 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. You will also design a DTD for a language called identifierList.The index.html fileThere will be exactly one HTML file in this application. It will be called index.html. When your web site isaccessed by a browser, the index.html file will request either a URL (from which your servlet application will fetchan XML document) or the text of an XML document with an imbedded DTD. If the XML document is fetchedfrom a URL then the server that provides that document must also provide the DTD referenced within thedocument. In either case, your servlet will receive a document and 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.Test Cases 195-733 Internet Technologies Carnegie Mellon University 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 Language DesignMany programming languages define an “identifier” as one or more letters followed by zero or more digits.Therefore, an identifier never begins with a digit, may be arbitrarily long and may end with a letter or digit. Definean “identifierList” as one or more identifier.Design a small internal DTD (like the ones you worked with above) that validates a document that contains oneidentifierList element. For example, the following document would be considered valid by the identifierList DTD.<identifierList> <identifier> <letter>N</letter> <letter>e</letter> <letter>t</letter> <digit>1</digit> <digit>0</digit> </identifier></identifierList> Test your grammar using the system developed in the first part of this lab.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. (2 Point)2) Within the envelope, a printout of four files: index.html, XMLHandler.java, ValidateBean.java andidentifierList.xml (7


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?