/**
  * tests if the manual set namespaceprefix 'foo' overwrites the prefix 'rdf' defined in
  * the default_prefixes array.
  */
 function testOverwritingDefaultManual()
 {
     $_SESSION['test'] = 'Overwriting default manual test';
     $model = new MemModel();
     $pars = new N3Parser();
     $model = $pars->parse2model($this->_generateModelString());
     $ser = new RdfSerializer();
     $string = $ser->serialize($model);
     $model2 = new MemModel();
     $model2->load($string);
     $this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI], 'rdf');
     $model2->addNamespace('foo', RDF_NAMESPACE_URI);
     $this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI], 'foo');
     $model2->removeNamespace(RDF_NAMESPACE_URI);
     //$this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI] , null);
 }
$stmts = mapSingleFormField($userURI, "location", FOAF . "based_near", "", true);
$stmtsAll = array_merge($stmtsAll, $stmts);
$stmts = mapSingleFormField($userURI, "dblp_uri", OWL . "sameAs", "", true);
$stmtsAll = array_merge($stmtsAll, $stmts);
$stmts = mapSingleFormField($userURI, "about_me_text", RDFS . "comment", "", false);
$stmtsAll = array_merge($stmtsAll, $stmts);
/* Now for the properties that can have multiple instances */
$stmts = mapSerializedFormField($userURI, "interests_serialized", CCO . "interest");
$stmtsAll = array_merge($stmtsAll, $stmts);
$stmts = mapSerializedFormField($userURI, "expertise_serialized", CCO . "expertise");
$stmtsAll = array_merge($stmtsAll, $stmts);
/*
 *  Now for the specialized goal properties, where both
 *  property and object needs to be read from form
 */
$stmts = mapGoalFields($userURI, "goals_serialized");
$stmtsAll = array_merge($stmtsAll, $stmts);
addStmtsToModel($model, $stmtsAll);
$ser = new RdfSerializer();
$ser->addNamespacePrefix("foaf", FOAF);
$ser->addNamespacePrefix("cco", CCO);
$ser->addNamespacePrefix("serena", SERENA);
$ser->addNamespacePrefix("rdfs", RDFS);
$ser->addNamespacePrefix("rdf", RDF);
$ser->addNamespacePrefix("owl", OWL);
$rawRDF = $ser->serialize($model);
$ser->saveAs($model, $fileName);
$options = array("indent" => "    ", "linebreak" => "\n", "typeHints" => false, "addDecl" => true, "encoding" => "UTF-8", "rootName" => "rdf:RDF", "rootAttributes" => array("version" => "0.91"), "defaultTagName" => "item", "attributesArray" => "_attributes");
$serializer = new XML_Serializer($options);
$serializer->serialize($rawRDF);
$serializedRDF = $serializer->getSerializedData();
Example #3
0
 /**
  * Writes the RDF serialization of the Model including ALL inferable 
  * triples.
  *
  * @access	public 
  * @return	string 
  */
 function writeRdfToString()
 {
     // Import Package Syntax
     include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
     $ser = new RdfSerializer();
     $rdf =& $ser->serialize($this->getMemModel());
     return $rdf;
 }
Example #4
0
    }
}
// Add document metadata to model
$doc = new Resource($documentURI);
$resource = new Resource($resourceID);
$rdf_type = new Resource(RDF_NAMESPACE_URI . RDF_TYPE);
$foaf_Document = new Resource("http://xmlns.com/foaf/0.1/Document");
$foaf_primaryTopic = new Resource("http://xmlns.com/foaf/0.1/primaryTopic");
$foaf_maker = new Resource("http://xmlns.com/foaf/0.1/maker");
$dc_license = new Resource("http://purl.org/dc/elements/1.1/license");
$rdfs_label = new Resource("http://www.w3.org/2000/01/rdf-schema#label");
$AWS_license = new Resource("http://www.amazon.com/AWS-License-home-page-Money/b/ref=sc_fe_c_0_12738641_12/102-8791790-9885755?ie=UTF8&node=3440661&no=12738641&me=A36L942TSJ2AJA");
$Google_license = new Resource("http://www.google.com/terms_of_service.html");
$bookmashup = new Resource("http://www4.wiwiss.fu-berlin.de/is-group/resource/projects/Project10");
$model->add(new Statement($doc, $rdf_type, $foaf_Document));
$model->add(new Statement($doc, $foaf_primaryTopic, $resource));
$model->add(new Statement($doc, $dc_license, $AWS_license));
$model->add(new Statement($doc, $dc_license, $Google_license));
$model->add(new Statement($doc, $foaf_maker, $bookmashup));
$model->add(new Statement($bookmashup, $rdfs_label, new Literal("RDF Book Mashup")));
// Output model as RDF/XML
header('Content-Type: application/rdf+xml; charset=utf-8');
include RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
$s = new RdfSerializer();
$s->addNamespacePrefix('foaf', 'http://xmlns.com/foaf/0.1/');
$s->addNamespacePrefix('rev', 'http://dannyayers.com/xmlns/rev/#');
$s->addNamespacePrefix('scom', 'http://sites.wiwiss.fu-berlin.de/suhl/bizer/bookmashup/simpleCommerceVocab01.rdf#');
$s->addNamespacePrefix('bookRdf', 'http://www.hackcraft.net/bookrdf/vocab/0_1/');
$s->addNamespacePrefix('owl', 'http://www.w3.org/2002/07/owl#');
$s->addNamespacePrefix('skos', 'http://www.w3.org/2004/02/skos/core#');
echo $s->serialize($model);
Example #5
0
        header("HTTP/1.1 500 Internal Server Error");
        echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'Flickr error #' . $FLICKRSERVICE->errCode, 'MESSAGE' => $FLICKRSERVICE->errMsg, 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
    } else {
        header("HTTP/1.1 404 Not Found");
        if (!isset($_REQUEST['item'])) {
            echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'Sorry, no photos found in the specified area', 'MESSAGE' => 'Please extend the search radius or verify the coordinates!', 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
        } else {
            if ($resourceFound) {
                echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'Sorry, no photos found for DBpedia.org resource ' . $_REQUEST['item'], 'MESSAGE' => 'You specified a valid resource, but we were unable to locate any photos for it!', 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
            } else {
                echo parameterize($HTML_TEMPLATE_ERROR, array('TITLE' => 'DBpedia.org resource ' . $_REQUEST['item'] . ' does not exist', 'MESSAGE' => 'Sorry, we were unable to find a resource at <a href="http://dbpedia.org">http://dbpedia.org</a> that matches your request!', 'FLICKRWRAPPR_HOMEPAGE' => FLICKRWRAPPR_HOMEPAGE));
            }
        }
    }
    exit;
} else {
    /* Output model */
    $ser = new RdfSerializer();
    $rdf = $ser->serialize($resultModel);
    if (clientAcceptsRDF()) {
        outputRdf($rdf);
    } else {
        /* Prepare HTML version */
        $res = $resultModel->sparqlQuery($QUERY_DISPLAY);
        $photos_html = "";
        foreach ($res as $line) {
            $photos_html .= parameterize($HTML_TEMPLATE_PHOTO, array("SRC" => $line['?img']->getURI(), "HREF" => $line['?flickrpage']->getURI()));
        }
        echo parameterize($HTML_TEMPLATE_RESULTS, array("TITLE" => $resultsLabel, "RDF" => htmlspecialchars($rdf), "PHOTOS_HTML" => $photos_html, "FLICKRWRAPPR_HOMEPAGE" => FLICKRWRAPPR_HOMEPAGE, "FLICKR_TOS_URL" => FLICKR_TOS_URL));
    }
}
Example #6
0
<?php

// ----------------------------------------------------------------------------------
// RDFDBUtils : RDF/XML
// ----------------------------------------------------------------------------------
/** 
 * This outputs RDF/XML for a model
 * 
 * @version $Id: rdf.php 523 2007-08-14 09:24:11Z cweiske $
 * @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 RdfSerializer();
    header("Content-Type: application/rdf+xml");
    header('Content-Disposition: inline; filename="model.rdf"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    print $s->serialize($m->getMemModel());
}
Example #7
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);
     }
 }
Example #8
0
            $model->add(new Statement($this_result, $foaf_depiction, new Resource($book['image'])));
        }
        foreach ($book['authors'] as $key => $author) {
            $this_author = new BlankNode("result{$i}_author" . ($key + 1));
            $model->add(new Statement($this_result, $dc_creator, $this_author));
            $model->add(new Statement($this_author, $foaf_name, new Literal($author)));
        }
        foreach ($book['subjects'] as $key => $subject) {
            $this_subject = new BlankNode("result{$i}_subject" . ($key + 1));
            $model->add(new Statement($this_result, $dc_subject, $this_subject));
            $model->add(new Statement($this_subject, $foaf_name, new Literal($subject)));
        }
    }
    header('Content-Type: application/rdf+xml; charset=utf-8');
    include RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
    $s = new RdfSerializer();
    $s->addNamespacePrefix('rdf', RDF_NAMESPACE_URI);
    $s->addNamespacePrefix('rdfs', RDF_SCHEMA_URI);
    $s->addNamespacePrefix('dc', DC_NS);
    $s->addNamespacePrefix('foaf', FOAF_NS);
    $s->addNamespacePrefix('search', SEARCH_NS);
    echo $s->serialize($model);
    exit;
}
?>
<html lang="en">
  <head>
    <title><?php 
if ($query) {
    ?>
Search Results: &#8220;<?php