예제 #1
0
<http://example.org/bat> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.org/Range1> .
') . '<BR>';
$inf->writeAsHtmlTable();
$inf2->writeAsHtmlTable();
echo '<BR><hr><BR>';
$inf->add(new Statement(new Resource('http://example.org/bas'), new Resource('http://www.w3.org/2000/01/rdf-schema#domain'), new Resource('http://example.org/Domain2')));
$inf->add(new Statement(new Resource('http://example.org/bas'), new Resource('http://www.w3.org/2000/01/rdf-schema#range'), new Resource('http://example.org/Range2')));
$inf2->add(new Statement(new Resource('http://example.org/bas'), new Resource('http://www.w3.org/2000/01/rdf-schema#domain'), new Resource('http://example.org/Domain2')));
$inf2->add(new Statement(new Resource('http://example.org/bas'), new Resource('http://www.w3.org/2000/01/rdf-schema#range'), new Resource('http://example.org/Range2')));
echo '<B>Added the following Triples :</B><BR>' . htmlentities('
<http://example.org/bas> <http://www.w3.org/2000/01/rdf-schema#domain> <http://example.org/Domain2> .') . '<BR>' . htmlentities('
<http://example.org/bas> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.org/Range2> .
') . '<BR>';
$inf->writeAsHtmlTable();
$inf2->writeAsHtmlTable();
$ser = new N3Serializer();
echo htmlentities($ser->serialize($inf));
echo '<BR><hr><BR>';
$inf->add(new Statement(new Resource('http://example.org/Domain2'), new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'), new Resource('http://example.org/Domain3')));
$inf->add(new Statement(new Resource('http://example.org/Domain3'), new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'), new Resource('http://example.org/Domain2')));
$inf2->add(new Statement(new Resource('http://example.org/Domain2'), new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'), new Resource('http://example.org/Domain3')));
$inf2->add(new Statement(new Resource('http://example.org/Domain3'), new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'), new Resource('http://example.org/Domain2')));
echo '<B>Added the following Triples (loop in the ontology) :</B><BR>' . htmlentities('
<http://example.org/Domain2> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/Domain3> .') . '<BR>' . htmlentities('
<http://example.org/Domain3> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/Domain2> .');
$inf->writeAsHtmlTable();
$inf2->writeAsHtmlTable();
echo '<BR><hr><BR>';
$inf->add(new Statement(new Resource('http://example.org/Range3'), new Resource('http://www.w3.org/2002/07/owl#sameAs'), new Resource('http://example.org/Range2')));
$inf2->add(new Statement(new Resource('http://example.org/Range3'), new Resource('http://www.w3.org/2002/07/owl#sameAs'), new Resource('http://example.org/Range2')));
echo '<B>Added the following Triple :</B><BR>' . htmlentities('
예제 #2
0
 function testNestBlankAtEnd()
 {
     $mod = new MemModel();
     $b3 = new BlankNode($mod);
     $mod->add(new Statement(new Resource('http://example.org/foo'), new Resource("http://example.org/bar2"), $b3));
     $ser = new N3Serializer();
     $ser->setCompress(true);
     $ser->setNest(true);
     $str = $ser->serialize($mod);
     //test if it can be loaded
     $par = new N3Parser();
     $mod2 = $par->parse2model($str, false);
     //var_dump($str, $mod2->triples);
     $this->compareModelsIgnoringBlankNodes($mod, $mod2);
 }
예제 #3
0
파일: n3.php 프로젝트: komagata/plnet
<?php

// ----------------------------------------------------------------------------------
// RDFDBUtils : N3
// ----------------------------------------------------------------------------------
/** 
 * This outputs N3 for a model
 * 
 * @version $Id: n3.php,v 1.5 2006/05/15 05:24:37 tgauss Exp $
 * @author   Gunnar AAstrand Grimnes <*****@*****.**>
 *
 **/
$needDB = true;
$needTables = true;
$needModel = true;
include "config.inc.php";
include "utils.php";
include "setup.php";
if ($db->modelExists($muri)) {
    $m = $db->getModel($muri);
    $s = new N3Serializer();
    header("Content-Type: application/rdf+n3");
    header('Content-Disposition: inline; filename="model.n3"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    print $s->serialize($m);
}
예제 #4
0
 /**
  * Saves the RDF,N3 or N-Triple serialization of the MemModel to a file.
  * You can decide to which format the model should be serialized by using a
  * corresponding suffix-string as $type parameter. If no $type parameter
  * is placed this method will serialize the model to XML/RDF format.
  * Returns FALSE if the MemModel couldn't be saved to the file.
  *
  * @access	public
  * @param 	string 	$filename
  * @param 	string 	$type
  * @throws   PhpError
  * @return	boolean
  */
 function saveAs($filename, $type = 'rdf')
 {
     // get suffix and create a corresponding serializer
     if ($type == 'rdf') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
         $ser = new RdfSerializer();
     } elseif ($type == 'nt') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
         $ser = new NTripleSerializer();
     } elseif ($type == 'n3') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
         $ser = new N3Serializer();
     } else {
         print 'Serializer type not properly defined. Use the strings "rdf","n3" or "nt".';
         return false;
     }
     return $ser->saveAs($this, $filename);
 }
예제 #5
0
파일: Rdf.php 프로젝트: Tjorriemorrie/app
 function MwRdfOutputTurtle($model)
 {
     global $wgOut, $_SERVER, $wgRdfNamespaces;
     $rdftype = wfNegotiateType(wfAcceptToPrefs($_SERVER['HTTP_ACCEPT']), wfAcceptToPrefs(MWRDF_TYPE_PREFS));
     if (!$rdftype) {
         wfHttpError(406, "Not Acceptable", wfMsg("notacceptable"));
         return false;
     } else {
         $wgOut->disable();
         header("Content-type: {$rdftype}; charset=utf-8");
         $wgOut->sendCacheControl();
         # Make sure serializer is loaded
         require_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
         $ser = new N3Serializer();
         foreach ($wgRdfNamespaces as $key => $value) {
             $ser->addNSPrefix($key, $value);
         }
         print $ser->serialize($model);
         return true;
     }
 }
예제 #6
0
 function serialize($format)
 {
     switch ($format) {
         case "html":
             $s = new RAPpubbyHTMLSer();
             return $s->serialize($this);
         case "n3":
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
             $s = new N3Serializer();
             return $s->serialize($this->m_rd);
         case "rdf/xml":
         default:
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
             $s = new RdfSerializer();
             return $s->serialize($this->m_rd);
     }
 }