DISC 3371 PARKS FINAL EXAM SPRING 2005

1. (75 points) The top row of a two frame HTML page is shown below:

Retrieved Text:

Keyword

CLICK HERE FOR THE ANSWER PAGE
This page contains a document a user has requested from the server. The server places the text of the requested document into a textarea (named returned_text with 10 rows, 80 columns). Additionally a textbox is provided for the user to search the text for a keyword they specify (the textbox is named keyword). Both elements are in a form named form0. When the user clicks on the "FIND and SHOW" button, a procedure named answer1 is executed. This procedure:
  1. retrieves the value of the textbox named keyword
  2. retrieves the text from the textarea named returned_text
  3. stores each sentence of the text in a globally defined array named sentence
    (Note: each sentence of the text ends in a carriage return/line feed sequence. This means that the ASCII character 13 is followed immediately by the ASCII character 10. They are not visible in the textarea but do cause each sentence to appear on a new line)
  4. searches the sentence array and identifies all sentences (i.e., lines of the textarea) where the keyword appears at least once (the search is case sensitive -- so EXACT matches only)
  5. writes a new document in the bottom frame on-the-fly that:
    1. shows each sentence that contains the keyword and its original line number
      (Each sentence shown is absolutely positioned in a span block with "Left:0" and a value of "Top" that vertically positions each sentence 40 pixels below the previous one. The first sentence has "top:40")
    2. displays the first occurence of the keyword in the sentence in a red font
    3. shows a count of the number of lines that contain the keyword (NOT the total number of occurrences)
    4. Makes a button visible that is labelled "SHOW XML" that cause a procedure named answer2 to be executed when clicked.
The second row frame is initially empty. Write the Javascript or Vbscript for the procedure named answer1 (you get to pick the language). Show NO HTML.

2. (25 points) When the user clicks the "SHOW XML" button, a procedure named answer2 is executed. This procedure utilizes the global array named sentence to create and display an XML representation of the returned document (i.e., the text in the textarea discussed above). The procedure:

  1. Creates an XML representation of the returned text using the following DTD:
    <?xml version="1.0"?>
    <!DOCTYPE returned_text [
    <!ELEMENT returned_text (sentence+)>
    <!ELEMENT sentence (#PCDATA) >
    ]
  2. displays the XML in the lower frame by creating a new page on-the-fly
To display XML in HTML you must replace the "<" characters with the string: "&lt;" and replace the ">" with the string "&gt;". Pick your language (vbscript or javascript) and write the code for answer2. Show NO HTML.