CSCI 4230.1
Software Tools
Fall 2000
Suggested Solution to Final Examination

(1)    For example,

<html>
<head>
<title>Random Quote</title>
<script language=Javascript>
<!-- Hide scripts from older browsers.

var UPDATE_PERIOD = 1000;
var quotes = new Array("I am hungry!!",
                       "Pass the burgers!!",
                       "CGI is fun.",
                       "Give me Perl or give me Java.",
                       "CGI.pm is good for your health.",
                       "You will meet a CGI expert and fall in love today.",
                       "XML is not the only markup language.",
                       "C++ is good!!");

function showQuote() {
    document.quoteform.quote.value = quotes[Math.floor(Math.random() * quotes.length)];
    setTimeout("showQuote()", UPDATE_PERIOD);
}
// -->
</script>
</head>
<body onload="showQuote()" bgcolor=yellow>
<h2 style="align:center;color:blue">Random Quotes</h1>
<p>
<form name="quoteform">
The Changing Random Quote
<p>
<input type="text" size="50" name="quote">
</form>
</body>

(2)    For example,

<body bgcolor="#CCCCFF">
<%
    set connection = Server.createObject("adodb.connection")
    connection.open "temp"  'DSN
%>
<h2 style="color:blue">School Information</h2>
<p>

<table border=1>
<tr>
   <th><span style="color:blue">District</span></th>
   <th><span style="color:blue">School</span></th>
   <th><span style="color:blue">Rating</span></th>
</tr>
<%
    sql = "select SchoolName, District, Rating from f00t2 order by District, SchoolName"
    Set ResultRS = connection.execute(sql)
    PrevDistrict = ""
 Schools = ""
 Ratings = ""
    do while not ResultRS.eof
    if (PrevDistrict <> ResultRS.fields("District")) then
    if (PrevDistrict <> "") then
              Response.write "<td>" & Schools & "</td><td>" & Ratings & "</td></tr>" & vbCrLf
    end if
    Schools = ""
    Ratings = ""
          Response.write "<tr><td valign=""top"">" & ResultRS.fields("District")
          PrevDistrict = ResultRS.fields("District")
    end if
    Schools = Schools & ResultRS.fields("SchoolName") & "<br>"
    Ratings = Ratings & ResultRS.fields("Rating") & "<br>"
    ResultRS.movenext
    loop
 if (Schools <> "") then
        Response.write "<td>" & Schools & "</td><td>" & Ratings & "</td></tr>" & vbCrLf
 end if
    connection.close
%>
</table>
</body>

(3)    (a)    For example,

<?xml version="1.0" ?>
<?xml-stylesheet href="t2aq4.css" type="text/css" ?>
<!DOCTYPE chapter SYSTEM "t2aq4.dtd">

<chapter>
   <author name="yue"/>
   <title>Linear Equation</title>
   <p>
      A linear equation can be solved easily.
      <example num="1">x + 5 &gt; y; 2*x -10 &lt; z </example>
      <example num="2">x + y = 10</example>
   </p>
   <p>
      A linear equation can be ...
   </p>
</chapter>

(b)   For example,

<!ELEMENT chapter (author, title, p*)>
<!ELEMENT author EMPTY>
<!ELEMENT title (#PCDATA)>
<!ELEMENT p (#PCDATA|example)*>
<!ELEMENT example (#PCDATA)>
<!ATTLIST author name CDATA #REQUIRED>
<!ATTLIST example num NMTOKEN #REQUIRED>