Due: Sunday, Mar. 24 by midnight,
in your cs639/pa2 directory.
In PA1, we turned Java source into XML appropriate to support the Package
Explorer in Eclipse. Now we will write a POX (plain old XML) servlet to supply the XML for one Java class at a time, and
the XML Schema file as well.. We will also write
two clients to accept and display the XML.You are
welcome to start from the posted solution to pa1b. Please report any problems
with that code.
The XML looks the same as in PA1, and now the basic XML schema is available in
$cs639/pa1bsoln. Just add a namespace http://schemas.cs.umb.edu/jsource
as a default namespace to the generated XML and to the XML Schema, and make it
the targetNamespace as well.
Implementation Notes
Getting Started. You need to install tomcat at home. See the linked docs
on these topics under Resouces/tomcat and Resouces/servlets on the class
web page. Post any problems to the Google group, preferably before Mar.
7. Bring up servlet1 and servlet2 as a first servlet
projects, following the instructions in TomcatSetupForPC.html.
Then merge your pa1b or the posted pa1b solution and servlet2. Note that pa1b
is a Java project but servlet2 is a Dynamic Web project, as is pa2. You can
merge outside eclipse and then bring up a new Dynamic Web project, or try to
merge inside eclipse, although this can be tricky. One trick I was slow to
notice: you can shift-click to select a group of files in Project Explorer,
then control-C to copy, then select a target package for them and control-V to
paste the files into the other package (possibly in another project.)
Tracking the Element Hierarchy
when using SAX, needed for pa2
When working with SAX, you have to track the element hierarchy yourself, you can't ask SAX what the parent of a given element is (unlike DOM).
In pa2 getting the full name of the method requires tracking the class hierarchy. Given an xml document, we can find the path of any element using the following approach with a SAX parser:
startDocument: create a stack of type String
startElement: push the local name onto the stack
endElement: pop the top String on the stack
endDocument: the stack should be empty
Example 6.7 uses this approach (ignore the JTree GUI).
Also, for pa2, note that TestXPath has ancestry-related code (climbs the tree),
which is easier than in the SAX case because a DOM tree has been created here.
Packages. Use package
cs639.presentation for the top-level client programs, cs639.servlet for
the top-level servlet code, cs639.xpath
for the XPath support (use a new filename since
"TestXPath" sounds like a JUnit test) and cs639.sax for the SAX code. Continue
to use cs639.jsource for the java source/reflection related code.
Files for grading: Hopefully you haven't needed to change the jsource code, except as needed for namespaces. Note
in memo.txt if you did change it.
In pa2, optionally, README with notes to grader/instructor
In pa2: build.xml, with targets test1[ab], test2[ab], test3[ab], test4[ab], and test5.
In pa2: memo.txt (with one-sentence descriptions)
In pa2/WebContent: welcome.html: HTML with
links for Grid.xml, SortEx.xml, and javaSource.xsd.
In pa2/WebContent/WEB-INF: web.xml, classes dir
In pa2/WebContent/WEB-INF/schema: javaSource.xsd with
targetNamespace added
In pa2/src/cs639/jsource: pa1a code, yours or posted solution
In pa2/src/cs639/validation: pa1a code, yours or
posted solution
In pa2/src/cs639/presentation:
JSourceClient1.java, JSourceClient2.java
In pa2/src/cs639/servlet:
JSourceServlet.java, plus helper sources.
In pa2/src/cs639/xpath:
*.java (nothing starting with "Test" unless you are using JUnit)
In pa2/src/cs639/sax: *.java (nothing starting
with "Test" unless...)