CSCI 4230.1
Software Tools
Spring 2000
Suggested Solution to Final Examination

(1)    For example,

<HTML>
<HEAD>
   <TITLE>List a column values from a table</TITLE>
</HEAD>

<BODY bgcolor="#ccccff">
<CFIF IsDefined("URL.ColumnName")>
    <CFSET ColumnName=URL.ColumnName>
</CFIF>
<CFIF Not IsDefined("ColumnName")>
   Please include the column name of the table in your url in the format of ColumnName=yourcolumnnmae.
   <P>
   The available column names are: EmployeeId, FullName, EMailAddress and Country.
<CFELSE>
   <!---  print sql resullt.  --->
   <CFTRY>
      <CFSET DBError = "N">
      <CFQUERY NAME="SQLQUERY" DATASOURCE="yue">
         select distinct #ColumnName# from s00t2q1
      </CFQUERY>
   <CFCATCH TYPE="Database">
      <CFSET DBError = "Y">
   </CFCATCH>
   </CFTRY>

   <CFIF DBError IS "Y">
      Your column names do not exist.
      The avaiable column names are: EmployeeId, FullName, EMailAddress and Country.
   <CFELSE>
      <CFOUTPUT>Distinct Values of <SPAN STYLE="color:blue">#ColumnName#</SPAN>:<p>
      </CFOUTPUT>
      <CFLOOP QUERY="SQLQUERY">
         <CFOUTPUT><TD>#EVALUATE("SQLQUERY.#ColumnName#")#</CFOUTPUT><BR>
      </CFLOOP>
   </CFIF>
</CFIF>
</BODY>
</HTML>

(2)    For example,

javascript:alert("Number of Images: "+document.images.length); void(null);

(3)    For example,

<body bgcolor="#ccccff">
<%
   strXML = Request.Form("xml")

   '   Invoke XML DOM Parser
   Set objXML = Server.CreateObject("Microsoft.XMLDOM")
   objXML.async = False
   objXML.validateOnParse = False
   objXML.LoadXML(strXML)

   If objXML.parseError.errorCode <> 0 Then
       Response.write "Sorry, your XML string contains error.<BR>"
       Response.write "Line: " & objXML.parseError.line & ": " & objXML.parseError.reason
   Else
       Set objList = objXML.documentElement.childNodes
       Response.write "There are " & objList.length & " top level children nodes in your XML string."
   End If
%>
</body>

(4)    For example,

<!ELEMENT class (title, instructor, student+)>
<!ELEMENT student (firstName, lastName|#PCDATA)>
<!ATTLIST student status (graduate|undergraduate) #IMPLIED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT instructor (#PCDATA)>
<!ELEMENT firstName (#PCDATA)>
<!ELEMENT lastName (#PCDATA)>