CS639 Homework 1 Web basics, XML Validation, Intro to ant, etc.
Due Thurs., Feb. 2, in class, on paper. Fixed part in yellow
highlight.
1. Basic HTML and HTML links.
- Learn about absolute and relative URLs, say by looking
at this tutorial
on
URLs
- Study the HTML tutorials linked to the class web page,
mainly links and images. We are not studying
"presentation", that is, the details of how a page looks to a
user.
Use a plain editor like emacs to compose a web page test1.html with
page title "Mytitle", contents entitled "Important links", and a
relative link to a copy of this file hw1.html in the same directory
as test1.html, and an absolute link to the root of our departmental
website, with appropriate descriptive text for the user to see.
Then have a link to Google labeled "latest Java XML news" that
searches for "java XML news". The easy way to do this is to
use Google interactively and copy the URL from the browser's address
window. But simplify the query string in it (after the ?) down
to the minimum that has these keywords and still works.
Include the text of test1.html in your homework submission.
2. Review Java Collection classes. Look at the Collection
Framework
home
page at Sun, and from there the Collections Framework Overview
and Collections Framework Annotated Outline docs at Sun, for Java
1.6.1. If you have been using Java 1.4, note that with Java
1.5/1.6/1.7, aka Java 5/6/7, we can (and should) use generics such
as List<Integer>
numbers
= new ArrayList<Integer>(); In Java 1.4, we
previously put List numbers =
new ArrayList(); and hoped we don't stick something other
than an Integer in numbers
by mistake. If you are new to Java 5/6/7, or need a brush up,
read the Tutorial linked to that same Collection Framework home
page.
a. What are the two most important concrete classes that
are available in the JDK for the Set interface? the Map
interface?
b. What is the immediate superclass to HashMap? Can it
be used with "... x = new ..." to create a new object?
Explain your answer.
c. Explain how you can find all the elements of a given
Set object. Does your answer also apply to Lists? other
things? what class of objects?
d. Explain how you can find all the keys of a given Map.
e. Consider a certain Set object s, with elements e1 and e2,
and another object x of the same type as e1 and e2. What tests on x
vs. e1 and e2 determine whether x is considered to be in set s or
not? In particular, what element-class methods are called by the Set
implementation code to make this determination.
f. Write a Java fragment that
creates a Map from String to Integer. Add the association
"x" -> 1.
3. XML Well-formedness. Find the error in
$cs639/campus-not-well-formed.xml and describe it.
Hint: try to display it in a browser. Fix the error and
show a snippet of XML around your fix in your homework paper.
4. XML Validation. Login in on our Linux host and copy everything
from $cs639/validate to your own cs639/hw1/validate ("cp -r
$cs639/validate ." while cd'd to hw1). Recompile Counter.java as a
check of your Java setup. See README there for some useful info.
a. Run Counter on each of the 6 *greeting*.xml files in validate,
using appropriate flags for each, and report the flags used and the
output
b. Run Counter on the other invalid greetings.xml displayed in Chap.
20 of the XML Bible--call them invalid_greetings1.xml and
invalid_greetings2.xml.
d. What does this validator report for campus-not-well-formed.xml?
5. Start learning or reviewing ant. First make sure you
understand command-line use of javac and java with packages, by
reading this Packages
tutorial. Read the ant tutorials linked from the class web
page.
a. In the Hello World tutorial, the javac and java commands
are set up for the case that the user is cd'd to the project base
directory, where src and build appear as subdirectories. Suppose the
user cd's to the src directory: what are the corresponding javac and
java commands in that case?
b. Find and read the details on the ant delete task at the
site where the tutorial resides. What does the line <delete
dir="build"/> do? What is the corresponding command on
UNIX? on Windows?
c. Modify the build.xml of the first example in the Hello
World tutorial for "oata.HelloWorld" to be for the same java file
(except for the package declaration) but now made to be in package
"com.oata", following the usual convention that the package name is
the site name in reverse order. (Only one tiny change is
needed, showing the ease of refactoring this way with ant.)
What is the new location for the source file?
6. Give a quick report on your software installation for this
course.
a. Have you done the setup for Linux, or optionally Linux/UNIX? (get
cs639 account, test java and ant, define $cs639 and test it, get rid
of any lingering CLASSPATH definitions) Report any problems.
b. Have you installed the Java6/7 JDK on your home PC? Any problems?
c. Have you installed eclipse JEE on your home PC? Any problems?
d. Have you set your user environment variables JAVA_HOME and
ANT_HOME, and added their bin directories to Path?
e. Did all the tests pass?