$value) { $clean[$key] = $value; } $xoclc = $clean['oclc']; $type = $clean['type']; //Get the III record number from XML $fname = "http://elibrary.wayne.edu/xmlopac/o$xoclc/1/1/1/10?link=i1-2&nodtd=y&noexclude=WXROOT.Heading.Title.IIIRECORD"; $brec = getXMLData('//RECORDKEY', $fname); //Check if the link is from the catalog or is headed to the reference form, based on a type=1 parameter (which only the catalog has) if ($type == 1) { //check for number of copies $nc = GetScreenScrapeCountUnique($brec); //perform a switch based on the number of copies switch ($nc) { case ($nc == 1): //one record, show map directly //Get the location $loc = GetScreenScrapeLocation($brec); //Get the call number $call = GetScreenScrapeCall($brec); //Get the map code $mapId = GetMapCode($loc); //redirect the page to map_display, passing the mapId and call number header('Location: map_display.php?mapId=' . $mapId . '~' . $call); break; case ($nc > 1): //more than one record, show selector, has location include('map_select.php'); break; case ($nc == 0): //no record count, redirect to reference.php (error) page - this should not happen header('Location: reference.php'); } } else { //redirects to reference form if the type is blank header('Location: map_callnumber.php'); } //##################### Functions ############################# function getXMLData($query, $xmlDocument) { //setup DomDocument $xp = createDomDoc($xmlDocument); //do the xpath query $nodes = $xp->query("$query"); //return the node value foreach ($nodes as $node) { $n = $node->textContent; } //return string with element value return $n; } function createDomDoc($xmlDocument, $reset = false) { static $x; if (!isset($x) || $reset) { $dom = new DomDocument(); $dom->load($xmlDocument); $x = new domxpath($dom); } return $x; } ?>