public function EasyRdf_Parser_RdfXml::parse

Parse an RDF/XML 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::parse

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php, line 779

Class

EasyRdf_Parser_RdfXml
A pure-php class to parse RDF/XML.

Code

public function parse($graph, $data, $format, $baseUri) {
  parent::checkParseParams($graph, $data, $format, $baseUri);
  if ($format != 'rdfxml') {
    throw new EasyRdf_Exception("EasyRdf_Parser_RdfXml does not support: {$format}");
  }
  $this
    ->init($graph, $baseUri);
  $this
    ->resetBnodeMap();

  /* xml parser */
  $this
    ->initXMLParser();

  /* parse */
  if (!xml_parse($this->xmlParser, $data, false)) {
    throw new EasyRdf_Exception('XML error: "' . xml_error_string(xml_get_error_code($this->xmlParser)) . '" at line ' . xml_get_current_line_number($this->xmlParser));
  }
  xml_parser_free($this->xmlParser);
  return $this->tripleCount;
}