public function EasyRdf_Serialiser_Turtle::serialise in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php \EasyRdf_Serialiser_Turtle::serialise()
Serialise an EasyRdf_Graph to Turtle.
Parameters
EasyRdf_Graph $graph An EasyRdf_Graph object.:
string $format The name of the format to convert to.:
array $options:
Return value
string The RDF in the new desired format.
Throws
Overrides EasyRdf_Serialiser::serialise
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Serialiser/ Turtle.php, line 340
Class
- EasyRdf_Serialiser_Turtle
- Class to serialise an EasyRdf_Graph to Turtle with no external dependancies.
Code
public function serialise($graph, $format, array $options = array()) {
parent::checkSerialiseParams($graph, $format);
if ($format != 'turtle' and $format != 'n3') {
throw new EasyRdf_Exception("EasyRdf_Serialiser_Turtle does not support: {$format}");
}
$this->prefixes = array();
$this->outputtedBnodes = array();
$turtle = '';
$turtle .= $this
->serialiseSubjects($graph, 'uri');
$turtle .= $this
->serialiseSubjects($graph, 'bnode');
if (count($this->prefixes)) {
return $this
->serialisePrefixes() . "\n" . $turtle;
}
else {
return $turtle;
}
}