You are here

public function EasyRdf_Parser_Rapper::parse in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rapper.php \EasyRdf_Parser_Rapper::parse()

Parse an RDF document into an EasyRdf_Graph

Parameters

object EasyRdf_Graph $graph the graph to load the data into:

string $data the RDF document data:

string $format the format of the input data:

string $baseUri the base URI of the data being parsed:

Return value

integer The number of triples added to the graph

Overrides EasyRdf_Parser_Json::parse

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rapper.php, line 82

Class

EasyRdf_Parser_Rapper
Class to parse RDF using the 'rapper' command line tool.

Code

public function parse($graph, $data, $format, $baseUri) {
  parent::checkParseParams($graph, $data, $format, $baseUri);
  $json = EasyRdf_Utils::execCommandPipe($this->rapperCmd, array(
    '--quiet',
    '--input',
    $format,
    '--output',
    'json',
    '--ignore-errors',
    '--input-uri',
    $baseUri,
    '--output-uri',
    '-',
    '-',
  ), $data);

  // Parse in the JSON
  return parent::parse($graph, $json, 'json', $baseUri);
}