In this assignment, you will work with a collection of assigned phone numbers stored in an XML document. You will use various XML technologies to perform certain tasks:
Write a DTD to define the structure of an XML document representing the information stored by the phone company for a client. Your DTD should support the following aspects:
You may find it helpful to develop the DTD along with an example XML document of the desired type. The most convenient way to do this is by embedding the DTD definition directly in the header of the document. That is, you can write something like:
<?xml version="1.0"?>
<!DOCUMENT phone_book [
<!ELEMENT ... etc ... >
<!ATTLIST ... etc ... >
]>
<!-- your xml document goes here -->
This way you can gradually refine your DTD, as you extend and expand your example. Validate your document as you go, possibly by using an online XML document validator (e.g., http://www.stg.brown.edu/service/xmlvalid/).
Be sure your final submission of your DTD is as a separate document, however, not embedded in some example XML document.
Use XSLT to create an HTML page from a phone book XML document (conformant to your DTD from Part 1). The resulting HTML document should have (at least) the following features:
You should use the Xalan XSLT processor, installed at /class/sce/local/xalan. The documentation for this processor can be found at http://xml.apache.org/xalan-j/getstarted.html. There are some useful examples under the installation directory.
The HTML should be generated by running xalan.xslt.Process directly (however, you can also use the xml-stylesheet processing instruction within the document itself). For example, we expect to run:
setenv XALAN_ROOT /class/sce/local/xalan
setenv XALAN_PATH {$XALAN_ROOT}/xalan.jar:{$XALAN_ROOT}/serializer.jar:{$XALAN_ROOT}/xml-apis.jar:{$XALAN_ROOT}/xercesImpl.jar
java -cp $XALAN_PATH org.apache.xalan.xslt.Process -in book.xml -xsl phone_book.xsl -out book.html
Write a Java application for phone number look-up. Your application should run from the command line, taking a single argument: the name of the XML document containing the customer data. Your application should support both lookup and reverse lookup functionality. For the former, the user should be prompted to enter a target last name and the application should retrieve the corresponding number(s). For the latter, the user should be prompted to enter a target number and the application should retrieve the corresponding last name. For simplicity, your application can ignore the "unlisted" aspect of customer data (ie treat all customer entries as retrievable).
Your application should use the SAX API, as provided by the Xerces XML parser, installed at /class/sce/local/xerces. The documentation for this parser can be found at http://xerces.apache.org/xerces2-j/. There are some useful examples under the installation directory.
You will probably compile your program with something like the following:
setenv XERCES_ROOT /class/sce/local/xerces
setenv XERCES_PATH {$XERCES_ROOT}/xml-apis.jar:{$XERCES_ROOT}/xercesImpl.jar
javac -cp .:{$XERCES_PATH} Finder.java
And run the program with:
java -cp .:{$XERCES_PATH} Finder book.xml
You should submit the following:
Submit all your files with the usual command:
submit c794aa lab7 book.xml phone_book.dtd phone_listing.xsl ...
No hard-copy submission is required.