addRDFXML() public method

As for addTurtle but load a string of RDF XML
See also: addTurtle
public addRDFXML ( $base, $data )
示例#1
0
<?php

if (is_null($_REQUEST['URI'])) {
    die("no URI");
}
$uri = $_REQUEST['URI'];
$rdf = "";
$uri = preg_replace("/^(?!http:\\/\\/)/", "http://", $uri);
$objsrc = file_get_contents($uri);
include_once "../Graphite.php";
include_once "../arc/ARC2.php";
$g = new Graphite();
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mimetype = $finfo->buffer($objsrc);
if ($mimetype == "application/RDF+XML") {
    $g->addRDFXML("", $objsrc);
    $rdf = $objsrc;
} elseif ($mimetype == "text/turtle") {
    $g->addTurtle("", $objsrc);
    $rdf = $objsrc;
} elseif ($mimetype == "text/html") {
    //Try to get RDFXML link in the link section in the head
    //	$rdfuri = "";
    //	$model = str_get_html($objsrc);
    //
    //	foreach( $model->find('head',0)->find('link') as $link ){
    //	if ($link->type == 'application/rdf+xml'){
    //	$rdfuri = $link->href;
    //	$rdf = file_get_contents($rdfuri);
    //	$uri = preg_replace("/rdf/","id", $rdfuri);
    //	$g->addRDFXML("", $rdf);
示例#2
0
<?php

include_once "Graphite.php";
include_once "arc/ARC2.php";
$rdf = $_REQUEST['rdf'];
$objuri = $_REQUEST['uri'];
$g = new Graphite(array('ecs' => 'http://rdf.ecs.soton.ac.uk/ontology/ecs#', 'eprel' => 'http://eprints.org/relation/', 'foaf' => 'http://xmlns.com/foaf/0.1/'));
if (is_array($rdf)) {
    foreach ($rdf as $r) {
        $g->addRDFXML("", $r);
    }
} else {
    $g->addRDFXML("", $rdf);
}
$gobj = $g->resource($objuri);
$gobj->loadSameAs();
$tags = array("foaf:img", "foaf:depiction", "eprel:haspreviewThumbnailVersion", "eprel:hasfullsizeThumbnailVersion");
$ret = "";
foreach ($tags as $tag) {
    $gpics = $gobj->all($tag);
    foreach ($gpics as $gpic) {
        if ($gpic->toString() == "[NULL]") {
            continue;
        }
        $atts = getimagesize($gpic->toString());
        if ($atts[0] < 100 || $atts[1] < 100) {
            continue;
        }
        $ret = $gpic->toString();
        break 2;
    }