CSc 8711. Databases and the Web
Spring 2011, Programming Project 4 (XML Parsing and Online Surveys)
Due: Sunday, April 3rd

In this project, you will write a Java application that processes XML files containing information about online surveys. The Java application takes as command line input an XML file name and produces as output the following four files:

  1. An HTML file that contains code to display the online survey on a browser. The HTML form should start with a textbox for respondent code into which anonymous survey takers entes a unique 5 digit number. We will assume that each survey taker is given a unique number by the survey organizer. The form should also have a comment text area at the end that can accept a comment from the survey taker. The HTML code must include Javascript to perform validation for value not chosen; We will assume that the user must choose one value for radio choices and at least one value for check box choices. The Javascript code should also validate the 5-digit respondent code.
  2. An Oracle SQL or MySQL script file that contains SQL statements to (a) create relational tables to store survey properties and insert insert the survey properties, and (b) create relational tables to store survey data submitted by the survey takers.
  3. A Java servlet or PhP source file containing code to process data submitted by the user using the data input form. The program should simply insert the data into the database table(s) created earlier.
  4. A Java servlet or PhP source file that contains code to display contents of the survey responses. For each question the data should be presented in two formats: (a) tabular format summarizing the number of respondents for each choices and (b) graphical format for the radio and check box choices. A graphical bar of fixed width and variable height depending on the number of respondents should be drawn side by side. The survey comments should also be displayed.

Online Survey XML file format

An online survey consists of one or more questions each with up to 5 responses (radio and check boxes only). For formatting purposes, some of the questions may be grouped together if they have the same responses. In this case, the HTML rendering should be in a tabular form with the first column for the question and the remaining columns for the responses. The response value should be in the column header and the individual cells should contain the radio buttons or check boxes.

Some sample online survey forms are shown below:

XML Schema

Write a XML Schema for the survey XML file and validate the XML file at the beginning; If the file is not validated, no output should be generated. For each question there should be at least one option.