public function EasyRdf_Parser_RdfXml::parse in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php \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
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ RdfXml.php, line 782
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)) {
$message = xml_error_string(xml_get_error_code($this->xmlParser));
throw new EasyRdf_Parser_Exception('XML error: "' . $message . '"', xml_get_current_line_number($this->xmlParser), xml_get_current_column_number($this->xmlParser));
}
xml_parser_free($this->xmlParser);
return $this->tripleCount;
}