protected function open() { $this->graph = new Graph(); $rdfa_parser = new RdfaParser(); $json_parser = new JsonLd(); \EasyRdf\RdfNamespace::set('dcat', 'http://www.w3.org/ns/dcat#'); \EasyRdf\RdfNamespace::set('lbld', 'http://decisions.data.vlaanderen.be/ns#'); $data = file_get_contents($this->extractor->uri); // Assume we have an rdfa document to begin with $rdfa_parser->parse($this->graph, $data, 'rdfa', $this->extractor->base_uri); // Check if we have properties we need to include into the current graph $properties = explode(',', $this->extractor->follow_properties); foreach ($this->graph->resources() as $resource) { foreach ($properties as $property) { $resolve_resources = $resource->allResources($property); if (!empty($resolve_resources)) { foreach ($resolve_resources as $resolve_resource) { $data = file_get_contents($resolve_resource->getUri()); // Parse any rdfa data in the document into the existing graph $this->graph->parse($data, 'rdfa', $resolve_resource->getUri()); $json = $this->parseJsonldSnippet($data); if (!empty($json)) { try { $this->graph->parse($json, 'jsonld', $resolve_resource->getUri()); } catch (\Exception $ex) { \Log::error("We could not parse json from the data, the data was:" . $json); } } } } } } // We only return the graph once as a full datastructure $this->has_next = true; }
protected function open() { $this->graph = new Graph(); $parser = new RdfaParser(); $data = file_get_contents($this->extractor->uri); $parser->parse($this->graph, $data, 'rdfa', $this->extractor->base_uri); // We only return the graph once as a full datastructure $this->has_next = true; }