public function EasyRdf_Parser_Arc::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_RdfPhp::parse

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Arc.php, line 74

Class

EasyRdf_Parser_Arc
Class to parse RDF using the ARC2 library.

Code

public function parse($graph, $data, $format, $baseUri) {
  parent::checkParseParams($graph, $data, $format, $baseUri);
  if (array_key_exists($format, self::$supportedTypes)) {
    $className = self::$supportedTypes[$format];
  }
  else {
    throw new EasyRdf_Exception("EasyRdf_Parser_Arc does not support: {$format}");
  }
  $parser = ARC2::getParser($className);
  if ($parser) {
    $parser
      ->parse($baseUri, $data);
    $rdfphp = $parser
      ->getSimpleIndex(false);
    return parent::parse($graph, $rdfphp, 'php', $baseUri);
  }
  else {
    throw new EasyRdf_Exception("ARC2 failed to get a {$className} parser.");
  }
}