CS639
Midterm Exam, Mar. 28, 2006, edited
for practice midterm, S12 NAME:_________________________
Open books, notes, handouts,
solutions, etc.
Show all work on these pages,
using backs of pages if needed. Total points
= 100, equally divided among numbered problems.
1.
Consider
expressing Javadoc information for a Java method in XML. Here is an example of such Javadoc (followed
by its method):
/**
* Runs a test of adding boxes to bins
* @param
sizes sizes of the boxes
* @param
collection The BinCollection to store the boxes
* @return
The number of bins
*/
public
static int runTest( int[]
sizes, BinCollection collection )
Assuming a standard Javadoc
format of optional general description, then any parameters, followed by any
return (and finally any throws, but let’s ignore this complication), design an
XML element named “MethodJavaDoc”.
Separately treat “sizes” and “The sizes of the boxes” for the first parameter
here (have them in different text nodes in the XPath sense.) Show how the content of this example Javadoc
would be written in XML in your design.
Don’t use any attributes.
2.
Provide a DTD for
your XML of 1.
3.
Provide an XML
Schema for your XML, in steps:
a.
Provide a type
definition for your parameter-related element’s type, starting like this:
<xsd:complexType
name="DocParamType">
b. Based on this type, provide a schema for the whole MethodJavaDoc
element. You don’t have to recopy (a)’s
text—we’ll assume it’s added at the end.
Here’s a start:
<?xml
version=”1.0”>
<xsd:schema
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<xsd:element name=”MethodJavaDoc”>
4. Web technology
Recall
this line of HTML from hw1’s solution:
<a
href='http://www.google.com/search?q=java+XML+news'>Latest Java XML
News</a>
a. If this HTML is displayed
in a browser, and the user clicks on this link, what happens?
Browser connects to host
________ , port _______
HTTP command:
Returns XML, HTML or what?
b.
Suppose we wanted
to disguise our use of Google by hiding the request to Google inside a
program. Rewrite the try { } of Example 2.3 to accomplish this, so that
“java URLGrabberTest” will cause the same output to be displayed.
5. Consider the solution for
pa1b, working on this little Box class:
public class Box {
private int height;
private static int count = 0;
public
Box(int height) { this.height = height; count++;}
public
int getHeight() {return height;}
private
void setHeight(int height) {this.height = height;}
public
static int getCount() { return count; }
public
static class BoxPart {
public int h;
public int getHeight() { return h; }
}
}
c.
What XML is
produced during the recursive call (processing BoxPart) to classToXML?
6. Consider pa2’s solution… To be added after the
pa2 solution is available.