Unformatted text preview:

Lab 3 Due: Wednesday, June 23, 2004 (Updated)XSDL Code Generation95-733 Internet Technologies Carnegie Mellon UniversityLab 3 Due: Wednesday, June 23, 2004 (Updated)XSDL Code GenerationPart I Working with Microsoft’s Infer.exeIt is assumed that you have downloaded and installed the Microsoft .NET Framework SDK. 1) Download and install Microsoft’s Infer.exe program from http://apps.gotdotnet.com/xmltools/xsdinference/2) Read the article on this utility at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/xsdinference.asp3) Run the command line Infer.exe tool against the following xml document instance (book1.xml). Note that this document contains an ISBN element. This was added after taking the document from the article above. <book year="1994" xmlns= "www.samplebookstore.com"> <title>TCP/IP Illustrated</title> <author>Stevens W.</author> <publisher>Addison-Wesley</publisher> <price> 65.95</price> <isbn>0201770598</isbn> </book>4) Visit the w3c site http://www.w3.org/TR/xmlschema-2 and change the xs:unsignedShort type found in the XSDL year attribute to a Gregorian year type. This is simply to illustrate the fact that the XSDL is changeable. We need not confine ourselves to the document generated by Infer.exe.5) Run JAXB against the XSDL document that you created in step 4. The JAXB code should now contain a getYear() method. What type of data is returned by getYear()? Is it the same type as that found in the XSDL document? Enter your answer here.6) Write a Java program that uses the API to read and manipulate the XML. The program will change the year of the book, and write the new XML document to the screen and back to disk. You will probably need to consult the JAXB directory under JWSDP for help with the marshalling and unmarshalling classes. Call this program ChangeYear.java and submit a listing of the source code. Paste a screen shot here showing the program running. 7) Modify the program ChangeYear.java and call it ChangeYearFromURL.java. Write ChangeYearFromURL.java so that it reads the XML source from 195-733 Internet Technologies Carnegie Mellon Universityhttp://www.andrew.cmu.edu/~mm6/bookdoc/book1.xml. It should still changethe year, display the modified file to the screen and write it to disk. It should make no attempt to change the file as it exists on Andrew. You will probably need to consult the JAXB directory under JWSDP for help with unmarshalling data using an internet URL. Submit a listing of the source code and paste a screen shot here of this program running.Part II Running Infer.exe on an RSS document1) Collect an RSS file from MIT. This file has the URL “http://mitworld.mit.edu/rss/new.xml”.2) Run Infer.exe using the RSS XML file as input.3) Run JAXB on the resulting XSDL document.4) Write a client (MITRSSReader.java) that will search the MIT RSS feed for a particular topic chosen by the user.5) Submit a printout of MITRSSReader.java and paste a screen shot here.Part III JSP ExampleIn part V you will be asked to build a web application using Java Server Pages. It may be helpful to build asimpler application first.1) Create a directory that will hold your application. In this example, I called my directory “jsp2”. Create two subdirectories called src and web. Under web create a directory called WEB-INF. Create a subdirectory under src called mybeans. 2) Place the build.properties file under jsp2. Place the build.xml file under jsp2.3) Create three additional files – web.xml, MyCoolBean.java and Somefile.jsp. These files are shown at the end of this assignment.4) Place MyCoolBean.java under src/mybeans and web.xml under web/WEB-INF. Your directory structure should now look like this:D:\McCarthy\www\95-733\examples\jsp2>tree /fFolder PATH listingVolume serial number is 71FAE346 BA17:BF69D:.│ build.properties│ build.xml│├───src│ └───mybeans│ MyCoolBean.java│└───web │ Somefile.jsp │ └───WEB-INF web.xml 5) You should now be able to startup Tomcat, install and then visit this web application. Paste two screen shots here showing a browser visiting this web application.295-733 Internet Technologies Carnegie Mellon University Summary of Submission Requirements:You must submit this final project in a large envelope.- Answer to question 5. 10 Points - ChangeYear.java 15 Points - Screen shot of ChangeYear.java 10 Points - ChangeYearFromURL.java 15 Points - Screen shot of ChangeYearFromURL.java 10 Points - MITRSSReader.java 20 Points - Screen shot of MITRSSReader.java 10 Points - JSP application screen shots 10 Points MyCoolBean.javapackage mybeans;import java.io.*;public class MyCoolBean implements Serializable { private int next; public int getNext() { return next++; } public void setNext(int m) { next = m; } public MyCoolBean() { next = 0; } }web.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd"><web-app></web-app> SomeFile.jsp <%@ page language="java" contentType="text/html" %> <html><body><h1>Helo Visitor </h1> <jsp:useBean id = "visit" scope = "application" class="mybeans.MyCoolBean" /> The visit number at the server is <jsp:getProperty name="visit" property="next" /></body>395-733 Internet Technologies Carnegie Mellon University</html>Book1.xml from the article at Microsoft<book year="1994" xmlns= "www.samplebookstore.com"> <title>TCP/IP Illustrated</title> <author>Stevens W.</author> <publisher>Addison-Wesley</publisher> <price> 65.95</price> </book>A JAXB build script: Build.xml<?xml version="1.0"?><project basedir="." default="run"> <path id="classpath"> <fileset dir="D:\jwsdp-1.3\jaxb\lib" includes="*.jar"/> <fileset dir="D:\jwsdp-1.3\common\lib" includes="*.jar"/> <fileset dir="D:\jwsdp-1.3\jaxp\lib\endorsed" includes="*.jar"/> <fileset dir="D:\jwsdp-1.3\jwsdp-shared\lib" includes="*.jar"/> <fileset dir="D:\jwsdp-1.3\jaxp\lib" includes="*.jar"/> <pathelement location="."/> </path> <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"> <classpath refid="classpath" /> </taskdef>


View Full Document

CMU ISM 95733 - Lab

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