示例#1
0
 /**
  * Parses an XML-formatted NCIP request or response
  * Throws Danmichaelo\QuiteSimpleXMLElement\InvalidXMLException on failure
  *
  * @param  string   $xml
  * @return QuiteSimpleXMLElement
  */
 public function parseXml($xml)
 {
     if (is_null($xml)) {
         return null;
     }
     $xml = new QuiteSimpleXMLElement($xml);
     $xml->registerXPathNamespaces($this->namespaces);
     return $xml;
 }
 private function parseRecordData($data)
 {
     $dom = new QuiteSimpleXMLElement('<?xml version="1.0"?>
         <marc:record xmlns:marc="info:lc/xmlns/marcxchange-v1" format="MARC21" type="Holdings">
             ' . $data . '
         </marc:record>');
     $dom->registerXPathNamespaces(array('marc' => 'http://www.loc.gov/MARC21/slim'));
     return new HoldingsRecord($dom);
 }
示例#3
0
 public function loadPrimoRecord($filename)
 {
     $xml = file_get_contents(__DIR__ . '/data/' . $filename);
     $root = new QuiteSimpleXMLElement($xml);
     $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search');
     $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib');
     $doc = $root->first('//s:DOC');
     $dl = new DeepLink('', '');
     return PrimoRecord::make($doc, $dl, false, [])->toArray(true);
 }
示例#4
0
 static function make(QuiteSimpleXMLElement $doc, DeepLink $deeplinkProvider, $expanded = false, $options)
 {
     $is_group = $doc->text('./p:PrimoNMBib/p:record/p:facets/p:frbrtype') != '6' && $doc->text('./p:PrimoNMBib/p:record/p:display/p:version', '1') != '1';
     if ($is_group && !$expanded) {
         $item = new PrimoRecordGroup($doc, $deeplinkProvider, $options);
     } else {
         $item = new PrimoRecord($doc, $deeplinkProvider, $options);
     }
     return $item->process();
 }
示例#5
0
 /**
  * Create a new Response
  *
  * @param  QuiteSimpleXMLElement  $dom
  * @return void
  */
 public function __construct(QuiteSimpleXMLElement $dom = null)
 {
     $this->dom = $dom;
     $this->success = false;
     if (is_null($this->dom)) {
         return;
     }
     if ($this->dom->first('ns1:Problem')) {
         $this->error = $this->dom->text('ns1:Problem/ns1:ProblemType');
         $this->errorDetails = $this->dom->text('ns1:Problem/ns1:ProblemDetail');
     } else {
         $this->success = true;
     }
 }
    public function testBasicCase()
    {
        $r = new QuiteSimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?>
			<record xmlns="http://www.openarchives.org/OAI/2.0/">
				<header>
					<identifier>oai:bibsys.no:biblio:113889372</identifier>
					<datestamp>2013-02-04T13:54:53Z</datestamp>
				</header>
				<metadata>
					The record
				</metadata>
			</record>');
        $r->registerXPathNamespaces(array('oai' => 'http://www.openarchives.org/OAI/2.0/'));
        $res = new Record($r);
        $this->assertEquals('oai:bibsys.no:biblio:113889372', $res->identifier);
        $this->assertEquals('2013-02-04T13:54:53Z', $res->datestamp);
        $this->assertEquals('The record', $res->data->text());
    }
示例#7
0
 protected function extractArray(QuiteSimpleXMLElement $group, $xpath)
 {
     return array_map(function ($x) {
         return $x->text();
     }, $group->all($xpath));
 }
示例#8
0
 /**
  * Create a new record
  *
  * @param Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement $doc
  */
 public function __construct($doc)
 {
     $this->identifier = $doc->text('oai:header/oai:identifier');
     $this->datestamp = $doc->text('oai:header/oai:datestamp');
     $this->data = $doc->first('oai:metadata');
 }
示例#9
0
 public function getRecord($docId, $options)
 {
     $institution = $options->get('institution', config('app.primo.institution'));
     $scope = $options->get('scope', config('app.primo.default_scope'));
     $queryObj = new Query($institution);
     $queryObj->local($scope);
     $queryObj->onCampus(true);
     $url = str_replace('json=true&', '', $this->primo->url('full', $queryObj));
     $url = str_replace('&indx=1&bulkSize=10', '', $url);
     $url .= '&docId=' . $docId . '&getDelivery=true';
     $client = new HttpClient();
     $request = $client->get($url);
     $body = $request->send()->getBody();
     if ($options->get('raw') == 'true') {
         return $body;
     }
     $root = new QuiteSimpleXMLElement(strval($body));
     $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search');
     $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib');
     $deeplinkProvider = $this->primo->createDeepLink();
     $error = $root->first('/s:SEGMENTS/s:JAGROOT/s:RESULT/s:ERROR');
     if ($error) {
         throw new PrimoException($error->attr('MESSAGE'), 0, null, $url);
     }
     $doc = $root->first('//s:DOC');
     if (!$doc) {
         throw new PrimoException('Invalid response from Primo', 0, null, $url);
     }
     $out = PrimoRecord::make($doc, $deeplinkProvider, true, $this->getRecordOptions($options))->toArray('full');
     return ['source' => $url, 'error' => null, 'result' => $out];
 }