class EasyRdf_Serialiser_Rapper in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Rapper.php \EasyRdf_Serialiser_Rapper
Class to serialise an EasyRdf_Graph to RDF using the 'rapper' command line tool.
Note: the built-in N-Triples serialiser is used to pass data to Rapper.
@package EasyRdf @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php
Hierarchy
- class \EasyRdf_Serialiser
- class \EasyRdf_Serialiser_Ntriples
- class \EasyRdf_Serialiser_Rapper
- class \EasyRdf_Serialiser_Ntriples
Expanded class hierarchy of EasyRdf_Serialiser_Rapper
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Serialiser/ Rapper.php, line 48
View source
class EasyRdf_Serialiser_Rapper extends EasyRdf_Serialiser_Ntriples {
private $rapperCmd = null;
/**
* Constructor
*
* @param string $rapperCmd Optional path to the rapper command to use.
* @return object EasyRdf_Serialiser_Rapper
*/
public function __construct($rapperCmd = 'rapper') {
$result = exec("{$rapperCmd} --version 2>/dev/null", $output, $status);
if ($status != 0) {
throw new EasyRdf_Exception("Failed to execute the command '{$rapperCmd}': {$result}");
}
else {
$this->rapperCmd = $rapperCmd;
}
}
/**
* Serialise an EasyRdf_Graph to the RDF format of choice.
*
* @param EasyRdf_Graph $graph An EasyRdf_Graph object.
* @param string $format The name of the format to convert to.
* @param array $options
* @return string The RDF in the new desired format.
*/
public function serialise($graph, $format, array $options = array()) {
parent::checkSerialiseParams($graph, $format);
$ntriples = parent::serialise($graph, 'ntriples');
// Hack to produce more concise RDF/XML
if ($format == 'rdfxml') {
$format = 'rdfxml-abbrev';
}
return EasyRdf_Utils::execCommandPipe($this->rapperCmd, array(
'--quiet',
'--input',
'ntriples',
'--output',
$format,
'-',
'unknown://',
), $ntriples);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EasyRdf_Serialiser:: |
protected | property | ||
EasyRdf_Serialiser:: |
protected | function | Keep track of the prefixes used while serialising @ignore | |
EasyRdf_Serialiser:: |
protected | function | Check and cleanup parameters passed to serialise() method @ignore | |
EasyRdf_Serialiser:: |
protected | function | Protected method to get the number of reverse properties for a resource If a resource only has a single property, the number of values for that property is returned instead. @ignore | |
EasyRdf_Serialiser_Ntriples:: |
private | property | ||
EasyRdf_Serialiser_Ntriples:: |
protected | function | @ignore | |
EasyRdf_Serialiser_Ntriples:: |
protected | function | @ignore | |
EasyRdf_Serialiser_Ntriples:: |
protected | function | @ignore | |
EasyRdf_Serialiser_Ntriples:: |
public | function | Serialise an RDF value into N-Triples | |
EasyRdf_Serialiser_Ntriples:: |
protected | function | @ignore | |
EasyRdf_Serialiser_Rapper:: |
private | property | ||
EasyRdf_Serialiser_Rapper:: |
public | function |
Serialise an EasyRdf_Graph to the RDF format of choice. Overrides EasyRdf_Serialiser_Ntriples:: |
|
EasyRdf_Serialiser_Rapper:: |
public | function |
Constructor Overrides EasyRdf_Serialiser:: |