function toRDFJSON($asObject = false) { $index = $this->toIndex(); $ser = ARC2::getRDFJSONSerializer(array('ns' => $this->ns)); if ($asObject) { return json_decode($ser->getSerializedIndex($index)); } return $ser->getSerializedIndex($index); }
public function printGraph() { /* Serializer instantiation */ $ser = \ARC2::getRDFJSONSerializer(); foreach ($this->objectToPrint as $class => $prop) { $triples = $prop->getTriples(); } /* Serialize a triples array */ echo $ser->getSerializedTriples($triples); }
function getRDFJSONDescribeResultDoc($r) { $this->setHeader('content-type', 'Content-Type: application/json'); $index = $r['result']; $ser = ARC2::getRDFJSONSerializer($this->a); $dur = $r['query_time']; $r = $ser->getSerializedIndex($index); if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { $r = $v . '(' . $r . ')'; } return $r; }
public static function serializeRdf($data, $extension = 'rdf') { global $conf; global $lodspk; $ser; $dPointer; $docs = Utils::travelTree($data); require_once $conf['home'] . 'lib/arc2/ARC2.php'; $parser = ARC2::getRDFParser(); $triples = array(); foreach ($docs as $d) { $parser->parse($conf['basedir'], $d); $t = $parser->getTriples(); $triples = array_merge($triples, $t); } if ($lodspk['mirror_external_uris']) { global $uri; global $localUri; $t = array(); $t['s'] = $localUri; $t['s_type'] = 'uri'; $t['p'] = "http://www.w3.org/2002/07/owl#sameAs"; $t['o'] = $uri; $t['o_type'] = 'uri'; array_push($triples, $t); $t['p'] = "http://www.w3.org/2000/10/swap/pim/contact#preferredURI"; array_push($triples, $t); } switch ($extension) { case 'ttl': $ser = ARC2::getTurtleSerializer(); break; case 'nt': $ser = ARC2::getNTriplesSerializer(); break; case 'json': $ser = ARC2::getRDFJSONSerializer(); break; case 'rdf': $ser = ARC2::getRDFXMLSerializer(); break; case 'html': return array("content" => $triples, "serialized" => false); break; default: $ser = null; } if ($ser != null) { $doc = $ser->getSerializedTriples($triples); } else { $doc = var_export($data, true); } return array("content" => $doc, "serialized" => true); }
break; default: $ser = ARC2::getTurtleSerializer(array('ns' => $ns)); break; } $output = ""; if ($outformat == "turtle") { $output = $ser->getSerializedTriples($triples); header("Content-Type: text/turtle"); } else { if ($outformat == "rdfxml") { $output = $ser->getSerializedTriples($triples); header("Content-Type: application/rdf+xml"); } else { if ($outformat == "json") { $ser = ARC2::getRDFJSONSerializer(array('ns' => $ns)); $output = $ser->getSerializedTriples($triples); } else { if ($outformat == "ntriples") { $output = $ser->getSerializedTriples($triples); header("Content-Type: text/plain"); } else { if ($outformat == "text") { $output = getTextFromTriples($triples); header("Content-Type: text/plain"); } else { $output = $ser->getSerializedTriples($triples); header("Content-Type: text/turtle"); } } }
function toRDFJSON() { $ser = ARC2::getRDFJSONSerializer(array('ns' => $this->ns)); return $ser->getSerializedIndex($this->index); }