/** * Parse a "relationship node", one that have links to other records encapsulated. * * @param QuiteSimpleXmlElement $node * * @return array */ protected function parseRelationship($node) { $rel = array(); $x = preg_replace('/\\(.*?\\)/', '', $node->text('marc:subfield[@code="w"]')); if (!empty($x)) { $rel['id'] = $x; } $x = $node->text('marc:subfield[@code="t"]'); if (!empty($x)) { $rel['title'] = $x; } $x = $node->text('marc:subfield[@code="g"]'); if (!empty($x)) { $rel['parts'] = $x; } $x = $node->text('marc:subfield[@code="x"]'); if (!empty($x)) { $rel['issn'] = $x; } $x = $node->text('marc:subfield[@code="z"]'); if (!empty($x)) { $rel['isbn'] = $x; } return $rel; }
/** * @param QuiteSimpleXmlElement|SimpleXmlElement $record */ public function parse($record) { if ($record instanceof SimpleXmlElement) { $record = new QuiteSimpleXmlElement($record); } elseif (!$record instanceof QuiteSimpleXmlElement) { throw new \Exception('Invalid type given to Parser->parse. Expected SimpleXmlElement or QuiteSimpleXmlElement', 1); } $leader = $record->text('marc:leader'); //99999 ai a22999997c 4500 $recordType = substr($leader, 6, 1); switch ($recordType) { case 'a': // Language material // Language material case 'c': // Notated music // Notated music case 'd': // Manuscript notated music // Manuscript notated music case 'e': // Cartographic material // Cartographic material case 'f': // Manuscript cartographic material // Manuscript cartographic material case 'g': // Projected medium // Projected medium case 'i': // Nonmusical sound recording // Nonmusical sound recording case 'j': // Musical sound recording // Musical sound recording case 'k': // Two-dimensional nonprojectable graphic // Two-dimensional nonprojectable graphic case 'm': // Computer file // Computer file case 'o': // Kit // Kit case 'p': // Mixed materials // Mixed materials case 'r': // Three-dimensional artifact or naturally occurring object // Three-dimensional artifact or naturally occurring object case 't': // Manuscript language material return new BibliographicRecord($record); case 'z': return new AuthorityRecord($record); case 'u': // Unknown // Unknown case 'v': // Multipart item holdings // Multipart item holdings case 'x': // Single-part item holdings // Single-part item holdings case 'y': // Serial item holdings return new HoldingsRecord($record); default: throw new ParserException("Unknown record type.\n\n------------------------\n" . $record->asXML() . "\n------------------------"); } }
/** * Parses common elements in subject added entry fields 600-655. * * @param \Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement $node * * @return array */ public function parseSubjectAddedEntry(QuiteSimpleXmlElement &$node) { $out = array('term' => '', 'vocabulary' => null); $vocabularies = array('0' => 'lcsh', '1' => 'lccsh', '2' => 'mesh', '3' => 'atg', '5' => 'cash', '6' => 'rvm'); $ind2 = $node->attr('ind2'); $id = $node->text('marc:subfield[@code="0"]'); $out['id'] = empty($id) ? null : $id; if (isset($vocabularies[$ind2])) { $out['vocabulary'] = $vocabularies[$ind2]; } elseif ($ind2 == '7') { $vocab = $node->text('marc:subfield[@code="2"]'); if (!empty($vocab)) { $out['vocabulary'] = $vocab; } } elseif ($ind2 == '4') { $this->parseAuthority($node->text('marc:subfield[@code="0"]'), $out); } $out['parts'] = array(); $subdivtypes = array('v' => 'form', 'x' => 'general', 'y' => 'chronologic', 'z' => 'geographic'); foreach ($node->all('marc:subfield') as $subdiv) { $code = $subdiv->attr('code'); if (in_array($code, array_keys($subdivtypes))) { $subdiv = trim($subdiv, '.'); $out['parts'][] = array('value' => $subdiv, 'type' => $subdivtypes[$code]); $out['term'] .= self::$subfieldSeparator . $subdiv; } } return $out; }