DISC 3371 PARKS FINAL EXAM FALL 2007 ANSWERS
<XML id="topo">
<?xml version="1.0"?>
<!DOCTYPE topo [
<!ELEMENT topo (east_long,west_long,north_lat,
     south_lat,width,height,feature+)>
<!ELEMENT east_long (#PCDATA) >
<!ELEMENT west_long (#PCDATA) >
<!ELEMENT north_lat (#PCDATA) >
<!ELEMENT south_lat (#PCDATA) >
<!ELEMENT width (#PCDATA) >
<!ELEMENT height (#PCDATA) >
<!ELEMENT feature (feature_long,feature_lat,feature_name)>
<!ELEMENT feature_long (#PCDATA) >
<!ELEMENT feature_lat (#PCDATA) >
<!ELEMENT feature_name (#PCDATA) >
]>
<topo>
<east_long>84.1479</east_long>
<west_long>84.1928</west_long>
<north_lat>35.8184</north_lat>
<south_lat>35.7910</south_lat>
<width> 800</width>
<height>600</height>
<feature>
  <feature_long>84.1703</feature_long>
  <feature_lat>35.8047</feature_lat>
  <feature_name>Parks Ferry (historical)</feature_name>
</feature>
<feature>
  <feature_long>84.1658</feature_long>
  <feature_lat>35.7971</feature_lat>
  <feature_name>Parks homestead</feature_name>
</feature>
<feature>
  <feature_long>84.1721</feature_long>
  <feature_lat>35.8093</feature_lat>
  <feature_name>Parks Ferry Road</feature_name>
</feature>
</topo>
</XML>
1. (50 points) A topographical map is loaded by an HTML page and is located absolutely positioned with: Top=0px; Left=0px; and z-index=2. An XML file is also included in an XML data island with id=topo as shown to the left. This XML file provides additional information about the topographical map that is loaded on the page. Specifically:
  • the sides of the map are defined by: the east longitude (right side of the map); the west longitude (the left side of the map); the north latitude (top of the map) and south latitude (the bottom of the map), are given as the first four children of <topo>
  • The width and height of the map is then given in pixels in the 5th and 6th children.
  • Three features then follow as the 7th, 8th and 9th children (indices 6,7 and 8). Each feature has a specific location expressed by a latitude and longitude and has a name.
When the page is loaded, execute a javascript function named p1. This function will gather the XML data from <topo> and identify each feature by placing a span block at the specified feature location on the map. The pixel location of the span block can be determined by the two formulas below:
1. The horizontal offset from the left side of the map is:
     width - width * ( feature longitude - east ) / ( west - east )
2. the vertical offset from the top of the map is:
     height - height * ( feature latitude - south ) / ( north - south )
Here north, south, east and west refer to the four map boundaries discussed above.
The span block contains: (1) a gif file named thex.gif; and (2) the text of the feature's name in red text (to the right of the gif). Note the span block must be positioned absolutely and have a z-index greater than 2. Assume the following div block is available to receive the span blocks on the page:

<div id="map_over" style=" style="position:absolute;Top:0px;Left:0px;"> </div>

Use root.childNodes(i).childNodes(j).text for children node values. Show no HTML. Show only the javascript for p1.

Click here for the answer to this question

George Washington's
State of the Union Addresses

Search for the string:

2.(50 points) All of George Washington's State of the Union Speeches are loaded into an array named a that contains 1,756 lines of text (and thus 1,756 array entries, beginning with index=0). A search feature for the speeches is shown to the left. It contains the ability to search for a string in the speeches by entering a string into the textbox (named sv in a form named f2) and pressing the "go" button. This button calls a javascript function named p2. The search output is to be displayed in a div block with id="d". Each of the speeches ends with a single line of text containing the three characters "***". There are eight speeches. The search string is case sensitive (i.e., capital letters matter). The display for each line where the search string occurs is:
  1. the text line number where the search string was found, followed by a period
    (anywhere from 0 to 1,755).
  2. the entire line of text with the first occurence of search string in red text.
  3. the speech number where the search string occurs in parenthesis.
Show no HTML. Show only the javascript for p2. Click 'VIEW', then 'SOURCE' for the answer to this question