The eXtensible Markup Language (XML)

Assignment #1

Due 2:00pm, July 23, 2001.

  1. In your home directory on cree.unl.edu, create a directory named csceXML for your assignments.

  2.     % mkdir  $HOME/csceXML;  chmod  0700  $HOME/csceXML
  3. Copy the directory cree:~reich/public_html/xml/SAX to a directory named a1 in your home.

  4.     % /bin/cp  -rp  ~reich/public_html/xml/SAX  $HOME/csceXML/a1
  5. Edit the file $HOME/csceXML/a1/wrox/sax/SAXParserHandler.java in the manner described below.
  6. Compile, test, and debug your program.  Make sure that your environment on cree is set up as described in:

  7.     http://cse.unl.edu/~reich/xml/cree-env.html
    To compile a Java program to a class file, use "javac".  For example:
        % javac  myjavacode.java
    To execute a compiled Java program, use "java".  For example:
        % java myjavacode
  8. When you have edited and debugged your code and are satisfied with the output, run the program to create output and store the output in the file $HOME/csceXML/a1/a1.txt:

  9.     % cd  $HOME/csceXML/a1;  java  SAXMain  >  a1.txt
  10. Run the handin program to turn in your work.

  11.     % handin  <class>  <hw#>  <file list>
    where the class is "cse496", the homework number is "1", and the file list consists of both the source code and the output.  There is a manual page accessible via "% man handin".
Here is an XML file with internal DTD subset declarations.

<?xml version="1.0" ?>
<!DOCTYPE message [
        <!ELEMENT message (source, (error | warning)+)>
        <!ELEMENT source (#PCDATA)>
        <!ELEMENT error (#PCDATA)>
        <!ATTLIST error level (low | high) "low">
        <!ELEMENT warning (#PCDATA)>
]>
<message>
<source>
/dev/dsk/dks2d1s0
</source>
<warning>
95% used
</warning>
<error>
write error
</error>
</message>

These messages will have a source element and one or more error and/or warning elements.  The error elements can have a level attribute with value "low" (default) or "high".

Rewrite the handler to recognize messages that have high-level errors.
If a message has a high-level, the program should print out the source and error.  If a message does not have a high-level error, the program should do nothing.

Create two examples, one message with a warning and a low-level error and a second message with a high-level error.  Demonstrate that your program works for both.