Source for file Serializer.php
Documentation is available at Serializer.php
// ----------------------------------------------------------------------------------
// Class: RDF_NTriple_Serializer
// ----------------------------------------------------------------------------------
* PHP N-Triple Serializer
* This class serialises models to N-Triple Syntax.
* @author Daniel Westphal <mail@d-westphal.de>
* Serializes a model to N Triple syntax.
* @param object Model $model
if (!is_a($m, 'RDF_Model_Memory')) {
if (!RDF_HIDE_ADVERTISE ) {
$this->res .= '# Generated by NTripleSerializer.php from RDF RAP.' .
RDF_LINEFEED . '# http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html'.
RDF_LINEFEED . RDF_LINEFEED;
foreach ($m->triples as $t) {
if (is_a($s, 'RDF_BlankNode')) {
$subject = '_:' . $s->getURI ();
$subject = '<' . str_replace(' ', '', $s->getURI ()) . '>';
$predicate = '<' . str_replace(' ', '', $p->getURI ()) . '>';
if (is_a($o, 'RDF_Literal')) {
$object = '"' . $o->getLabel () . '"';
if ($o->getLanguage () != '') {
$object .= '@' . $o->getLanguage ();
if ($o->getDatatype () != '') {
$object .= '^^<' . $o->getDatatype () . '>';
} elseif (is_a($o, 'RDF_BlankNode')) {
$object = '_:' . $o->getURI ();
$object = '<' . str_replace(' ', '', $o->getURI ()) . '>';
$this->res .= $subject . ' ' . $predicate . ' ' . $object . ' .';
$this->res .= RDF_LINEFEED . RDF_LINEFEED;
* Serializes a model and saves it into a file.
* Returns FALSE if the model couldn't be saved to the file.
* @param object Model_Memory $model
* @param string $filename
function saveAs(&$model, $filename)
// write serialized model to file
$file_handle = @fopen($filename, 'w');
/* ==================== protected Methods from here ==================== */
* Readies this object for serializing another model
Documentation generated on Mon, 11 Mar 2019 15:39:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|