class EasyRdf_Parser_RdfPhp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfPhp.php \EasyRdf_Parser_RdfPhp
Class to parse RDF with no external dependancies.
http://n2.talis.com/wiki/RDF_PHP_Specification docs/appendix-a-rdf-formats-php.md
@package EasyRdf @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php
Hierarchy
- class \EasyRdf_Parser
- class \EasyRdf_Parser_RdfPhp
Expanded class hierarchy of EasyRdf_Parser_RdfPhp
1 string reference to 'EasyRdf_Parser_RdfPhp'
- Format.php in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Format.php
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ RdfPhp.php, line 48
View source
class EasyRdf_Parser_RdfPhp extends EasyRdf_Parser {
/**
* Constructor
*
* @return object EasyRdf_Parser_RdfPhp
*/
public function __construct() {
}
/**
* Parse RDF/PHP 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) {
$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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EasyRdf_Parser:: |
protected | property | The base URI for the document currently being parsed | |
EasyRdf_Parser:: |
private | property | Mapping from source to graph bnode identifiers | |
EasyRdf_Parser:: |
protected | property | The format of the document currently being parsed | |
EasyRdf_Parser:: |
protected | property | The current graph to insert triples into | |
EasyRdf_Parser:: |
protected | property | ||
EasyRdf_Parser:: |
protected | function | Add a triple to the current graph, and keep count of the number of triples @ignore | 1 |
EasyRdf_Parser:: |
protected | function | Check, cleanup parameters and prepare for parsing @ignore | |
EasyRdf_Parser:: |
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:: |
protected | function | Delete the bnode mapping - to be called at the start of a new parse @ignore | |
EasyRdf_Parser_RdfPhp:: |
public | function |
Parse RDF/PHP into an EasyRdf_Graph Overrides EasyRdf_Parser:: |
2 |
EasyRdf_Parser_RdfPhp:: |
public | function | Constructor | 2 |