Unformatted text preview:

Lab 3 Due: Wednesday, June 23, 2004XSDL Code Generation95-733 Internet Technologies Carnegie Mellon UniversityLab 3 Due: Wednesday, June 23, 2004XSDL 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.295-733 Internet Technologies Carnegie Mellon UniversityPart IV JSP’s and JAXBIn Part V you will be placing JAXB code within the Java Web Services Developer Pack. Be sure to do the following:1) Set your JWSD_HOME environment variable to the path of your installation. Mine looks like this:JWSDP_HOME D:\jwsdp-1.22) Set your JAXB_HOME environment variable to JAXB’s path. Mine looks like this:JAXB_HOME D:\jwsdp-1.2\jaxb3) After running JAXB, copy all the directories that it creates to the WEB-INF/classes subdirectory4) Make sure that the build.xml file includes the JAXB jars in the classpath. This is the build.xml file that is used to install your web application under Tomcat. My build.xml file contains the following: <path id="compile.classpath"> <!-- Include all elements that Tomcat exposes to applications --> <pathelement location="${catalina.home}/common/classes"/> <fileset dir="${catalina.home}/common/endorsed"> <include name="*.jar"/> </fileset> <fileset dir="${catalina.home}/common/lib"> <include name="*.jar"/> </fileset> <pathelement location="${catalina.home}/shared/classes"/> <fileset dir="${catalina.home}/shared/lib"> <include name="*.jar"/> </fileset> <!-- these have been added for the JAXB related classes --> <fileset dir="D:\jwsdp-1.2\jaxb\lib" includes="*.jar"/> <fileset dir="D:\jwsdp-1.2\common\lib" includes="*.jar"/> <fileset dir="D:\jwsdp-1.2\jaxp\lib\endorsed" includes="*.jar"/> <fileset dir="D:\jwsdp-1.2\jwsdp-shared\lib" includes="*.jar"/> <fileset dir="D:\jwsdp-1.2\jaxp\lib" includes="*.jar"/> <pathelement location="."/> </path>5) Make sure that you have the files jaxb.properties and bgm.ser (both generated by JAXB) inside a subdirectory of WEB-INF/classes. This should have been automatic when you performed step 3.6) There is additional help from Sun at http://java.sun.com/xml/jaxb/jaxbWithTomcat.html7) Below is a display of my directory tree that I installed on Tomcat. There are too many files to show them all but I have added comments describing where things have been placed. 395-733 Internet Technologies Carnegie Mellon University D:.├───build build


View Full Document

CMU ISM 95733 - NewHomework3

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