Unformatted text preview:

Emerging Technologies Carnegie Mellon University Spring 2000 DUE: Monday May 8, 2000 Project 5 SAX Exercise Sun Microsystems has recently released a new Java API for XML parsing that includes support for DOM and SAX. This API can be downloaded from http://java.sun.com/xml/. It can also be found in A003 Hamburg Hall and in the GSIA FAST Lab. See the FAQ for directions on how to compile and run Java programs using this API from these labs.The Simple API for XML (SAX) may become an important tool for those wishing to process large XML documents. It may be used, for example, to convert large XML files into relational tables suitable for a database. IBM and others have also created similar software, implementing the World Wide Web Consortium’s DOM and SAX specifications. In this project we will get to explore SAX, Java, and DTD’s.In this project, you will write a Java program that uses Sun’s SAX API to evaluate arithmetic expressions in postfix notation. Your SAX program will be responding to method calls made by the SAX parser. The output of your program will be the values of all postfix expressions found in a valid xml document. The document that your program will read will conform to a DTD that you must create.The following is a list of example files that your DTD must validate:<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE expressiondoc SYSTEM "expressiondoc.dtd"> <expressiondoc> <postexp> <number>33</number> </postexp></expressiondoc>So, a <postexp> element may simply contain a <number> element. This document has one postfix expression whose value is 33. The output from your Java SAX program will read something like the following:C:\EmergingTechnologies\Project5>java Postexp expressiondoc.xmlPostfix expression = 33Document doneAn <expressiondoc> document may contain more than one postfix expression. As shown in the following example:<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE expressiondoc SYSTEM "expressiondoc.dtd"> <expressiondoc> <postexp> <number>33</number> </postexp> <postexp> <number>22</number> </postexp> <postexp> <number>45</number> </postexp></expressiondoc>Emerging Technologies Carnegie Mellon University The output from your Java SAX program will read something like the following:C:\ EmergingTechnologies\Project5>java Postexp expressiondoc.xmlPostfix expression = 33Postfix expression = 22Postfix expression = 45Document doneA postfix expression may also be of the form <postexp> <postexp> <operator>. For example, the following file will be accepted by your DTD and your Java program will produce the output as shown:<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE expressiondoc SYSTEM "expressiondoc.dtd"> <expressiondoc> <postexp> <postexp> <number>33</number> </postexp> <postexp> <number>2</number> </postexp> <operator>*</operator> </postexp></expressiondoc>C:\ EmergingTechnologies \Project5>java Postexp expressiondoc.xmlPostfix expression = 66Document doneOf course, the postfix expressions may be nested to arbitrary depths. Here is another example with output:<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE expressiondoc SYSTEM "expressiondoc.dtd"> <expressiondoc> <postexp> <postexp> <number>5</number> </postexp> <postexp> <number>2</number> </postexp> <operator>+</operator> </postexp> <postexp> <postexp> <number>33</number> </postexp> <postexp> <number>2</number> </postexp> <operator>/</operator> </postexp>Emerging Technologies Carnegie Mellon University <postexp> <postexp> <postexp> <number>33</number> </postexp> <postexp> <number>2</number> </postexp> <operator>/</operator> </postexp> <postexp> <number>2</number> </postexp> <operator>-</operator> </postexp> </expressiondoc>C:\ EmergingTechnologies \Project5>java Postexp expressiondoc.xmlPostfix expression = 7Postfix expression = 16Postfix expression = 14Document doneYour program must handle positive and negative integers and the operators ‘+’,’-‘,’/’,and ‘*’.Suggested approach:When you are writing code that responds to events, the appropriate model to use is often a finite state machine. It can be a very powerful and simple tool. Once it is designed, the programming is easy.Grading:The project will be graded according the following criteria:(1) Are comments included in the Java code so that it is clear what each section of the code is doing? Is the program easy to read? Is indentation used? 5 Points(2) Does your Java program use Sun’s Simple API for XML and does it work for various test cases including those above? 60 Points.(3) Is the DTD reasonable and does it work on the files above? Does it work with other .xml files that conform to the same structure as the examples? 30 Points(4) Have the submission guidelines been followed? 5 PointsPlease note that no projects (or late submissions) will be accepted after midnight (your local time) on May 8. If you have any old projects that need to be submitted, please do so before that time.Emerging Technologies Carnegie Mellon University Submission directories:Web Technologies: Your TA for this project is [email protected] Technologies: Your TA for this assignment is [email protected] the course account, a directory has been built for each enrolled student. Your directory is named yourAndrewID. For example if your E-Mail address is [email protected], the name of your directory is mm6.For those students registered for 46-929 Web Technologies, ftp or cp your .java files and your DTD file to the directory: /afs/4ndrew/course/46/929/yourAndrewID/project5/ For those students registered for 95-733 Internet Technologies, ftp or cp your .java files and


View Full Document

CMU ISM 95733 - Project

Download Project
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 Project 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 Project 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?