You are here

class EasyRdf_Parser_Arc in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Arc.php \EasyRdf_Parser_Arc

Class to parse RDF using the ARC2 library.

@package EasyRdf @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php

Hierarchy

Expanded class hierarchy of EasyRdf_Parser_Arc

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Arc.php, line 45

View source
class EasyRdf_Parser_Arc extends EasyRdf_Parser_RdfPhp {
  private static $supportedTypes = array(
    'rdfxml' => 'RDFXML',
    'turtle' => 'Turtle',
    'ntriples' => 'Turtle',
    'rdfa' => 'SemHTML',
  );

  /**
   * Constructor
   *
   * @return object EasyRdf_Parser_Arc
   */
  public function __construct() {
    require_once 'arc/ARC2.php';
  }

  /**
   * Parse an RDF document into an EasyRdf_Graph
   *
   * @param object EasyRdf_Graph $graph   the graph to load the data into
   * @param string               $data    the RDF document data
   * @param string               $format  the format of the input data
   * @param string               $baseUri the base URI of the data being parsed
   * @return integer             The number of triples added to the graph
   */
  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.");
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EasyRdf_Parser::$baseUri protected property The base URI for the document currently being parsed
EasyRdf_Parser::$bnodeMap private property Mapping from source to graph bnode identifiers
EasyRdf_Parser::$format protected property The format of the document currently being parsed
EasyRdf_Parser::$graph protected property The current graph to insert triples into
EasyRdf_Parser::$tripleCount protected property
EasyRdf_Parser::addTriple protected function Add a triple to the current graph, and keep count of the number of triples @ignore 1
EasyRdf_Parser::checkParseParams protected function Check, cleanup parameters and prepare for parsing @ignore
EasyRdf_Parser::remapBnode protected function Create a new, unique bnode identifier from a source identifier. If the source identifier has previously been seen, the same new bnode identifier is returned. @ignore
EasyRdf_Parser::resetBnodeMap protected function Delete the bnode mapping - to be called at the start of a new parse @ignore
EasyRdf_Parser_Arc::$supportedTypes private static property
EasyRdf_Parser_Arc::parse public function Parse an RDF document into an EasyRdf_Graph Overrides EasyRdf_Parser_RdfPhp::parse
EasyRdf_Parser_Arc::__construct public function Constructor Overrides EasyRdf_Parser_RdfPhp::__construct