/** * Parse the XML into objects * * @param \DOMDocument $document */ protected function parse(\DOMDocument $document) { $xpath = new \DOMXPath($document); $xpath->registerNamespace("marc", $this->namespace); $records = $xpath->query("//marc:record"); $this->_length = $records->length; foreach ($records as $record) { $marc_record = new Record(); $marc_record->loadXML($record); array_push($this->_records, $marc_record); } }
/** * Parse record information in alternate languae script * * Such as CJK, Cyrillic, etc. */ protected function parseAltScript() { // the 880 represents an alternative character-script, like hebrew or cjk if ($this->marc->datafield("880")->length() > 0) { // we create a new marc record from the 880, using subfield 6 as the // name of each new tag $marc = new MarcRecord(); foreach ($this->marc->datafield("880") as $datafield) { $datafield->tag = (string) $datafield->subfield("6"); $marc->addDataField($datafield); } $bibliogaphic = new Bibliographic(); $bibliogaphic->loadMarc($marc); array_push($this->alt_scripts, $bibliogaphic); } // now use the $6 to figure out which character-script this is // assume just one for now $alt_script = (string) $this->marc->datafield("880")->subfield("6"); if ($alt_script != null) { $match_codes_array = array(); $script_code_array = array("(3" => "Arabic", "(B" => "Latin", '$1' => "CJK", "(N" => "Cyrillic", "(S" => "Greek", "(2" => "Hebrew"); if (preg_match('/[0-9]{3}-[0-9]{2}\\/([^\\/]*)/', $alt_script, $match_codes_array)) { if (array_key_exists($match_codes_array[1], $script_code_array)) { $this->alt_script_name = $script_code_array[$match_codes_array[1]]; } } } }