public function EasyRdf_Parser_RdfPhp::parse in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfPhp.php \EasyRdf_Parser_RdfPhp::parse()
Parse RDF/PHP 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
2 calls to EasyRdf_Parser_RdfPhp::parse()
- EasyRdf_Parser_Arc::parse in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Arc.php - Parse an RDF document into an EasyRdf_Graph
- EasyRdf_Parser_Json::parse in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Json.php - Parse RDF/JSON into an EasyRdf_Graph
2 methods override EasyRdf_Parser_RdfPhp::parse()
- EasyRdf_Parser_Arc::parse in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Arc.php - Parse an RDF document into an EasyRdf_Graph
- EasyRdf_Parser_Json::parse in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Json.php - Parse RDF/JSON into an EasyRdf_Graph
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ RdfPhp.php, line 68
Class
- EasyRdf_Parser_RdfPhp
- Class to parse RDF with no external dependancies.
Code
public function parse($graph, $data, $format, $baseUri) {
$this
->checkParseParams($graph, $data, $format, $baseUri);
if ($format != 'php') {
throw new EasyRdf_Exception("EasyRdf_Parser_RdfPhp does not support: {$format}");
}
foreach ($data as $subject => $properties) {
if (substr($subject, 0, 2) === '_:') {
$subject = $this
->remapBnode($subject);
}
elseif (preg_match('/^\\w+$/', $subject)) {
# Cope with invalid RDF/JSON serialisations that
# put the node name in, without the _: prefix
# (such as net.fortytwo.sesametools.rdfjson)
$subject = $this
->remapBnode($subject);
}
foreach ($properties as $property => $objects) {
foreach ($objects as $object) {
if ($object['type'] === 'bnode') {
$object['value'] = $this
->remapBnode($object['value']);
}
$this
->addTriple($subject, $property, $object);
}
}
}
return $this->tripleCount;
}