ns() public method

Add an additional namespace alias to the Graphite instance.
See also: http://www.w3.org/TR/REC-xml-names/#ns-decl
public ns ( string $short, string $long )
$short string Must be a valid xmlns prefix. urn, http, doi, https, ftp, mail, xmlns, file and data are reserved.
$long string Must be either a valid URI or an empty string.
 public function getTree($node, $ontology)
 {
     $filename = getcwd() . "/cache/onto-" . urlencode($ontology->url) . ".json";
     if (is_readable($filename)) {
         return json_decode(file_get_contents($filename));
     }
     $count = new PrefixCounter($ontology->prefix);
     $graph = new Graphite();
     $xml = simplexml_load_file($ontology->url);
     foreach ($xml->getNamespaces(true) as $prefix => $uri) {
         $graph->ns($prefix, stripslashes($uri));
     }
     $graph->load($ontology->url);
     $classes = $graph->allOfType("owl:Class");
     $classes = $classes->append($graph->allOfType("rdfs:Class"));
     $toplevel = $classes->except($classes->all("-rdfs:subClassOf"));
     $json = array();
     foreach ($toplevel as $class) {
         $uri = $graph->shrinkUri($class);
         $children = Ontology::getChildren($graph, $class, $count);
         $count->step();
         $json[] = array("id" => $count->value(), "text" => $uri, "iconCls" => "class", "children" => $children, "leaf" => empty($children));
     }
     file_put_contents($filename, json_encode($json));
     return $json;
 }
Beispiel #2
0
<?php

include_once "arc/ARC2.php";
include_once "Graphite.php";
$graph = new Graphite();
$graph->ns("uosbuilding", "http://id.southampton.ac.uk/building/");
$graph->load("uosbuilding:32");
print $graph->resource("uosbuilding:32")->label();
Beispiel #3
0
<?php

include_once "../arc/ARC2.php";
include_once "../Graphite.php";
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
$map = array("http://purl.org/dc/terms/creator" => "Creator", "http://purl.org/dc/terms/created" => "Date created", "http://purl.org/dc/terms/visits" => "Visits", "http://purl.org/dc/terms/established" => "Established", "http://purl.org/dc/terms/version" => "Version", "http://purl.org/ontology/bibo/presentedAt" => "Presented at", "http://purl.org/ontology/bibo/contributor" => "Contributor", "http://purl.org/dc/terms/analyser" => "Analyser", "http://eprints.org/ontology/downloads" => "Downloads", "http://purl.org/dc/terms/sampleSize" => "Sample size");
$uri = "http://id.ecs.soton.ac.uk/project/644";
$rdfuri = "../results.rdf";
$graph = new Graphite();
$graph->ns("eprel", "http://eprints.org/relation/");
$graph->ns("ecs", "http://rdf.ecs.soton.ac.uk/ontology/ecs#");
$graph->load($rdfuri);
// attempt to get a value from a resource
// it will return the first non-null valued element from the array, or if none can be found return the placeholder
function get_from_rdf($resource, $element_order_array, $placeholder)
{
    global $graph;
    foreach ($element_order_array as $element) {
        $value = $graph->resource($resource)->get($element);
        if ($value != "[NULL]") {
            return htmlspecialchars_decode($value);
        }
    }
    return $placeholder;
}
// get the text for the head title
function main_head()
{
    global $uri;
    global $graph;
<?php

header("Content-Type:application/json");
include_once "arc2/ARC2.php";
include_once "arc2/Graphite.php";
$URL = $_GET['url'];
$CLASS = $_GET['class'];
$filename = getcwd() . "/cache/inst-" . urlencode($CLASS) . "-" . urlencode($URL) . ".json";
if (is_readable($filename)) {
    print file_get_contents($filename);
    return;
}
$graph = new Graphite();
$xml = simplexml_load_file($URL);
foreach ($xml->getNamespaces(true) as $prefix => $uri) {
    $graph->ns($prefix, stripslashes($uri));
}
$graph->load($URL);
$properties = array();
if (array_key_exists('properties', $_REQUEST)) {
    $PROPS = $_GET['properties'];
    $properties = explode(",", $PROPS);
}
// Here, we grab a List of all of this type of class
$resources = $graph->allOfType($CLASS);
$json = array();
foreach ($resources as $instance) {
    $suri = $graph->shrinkURI(trim($instance));
    $add = array("id" => $suri);
    foreach ($properties as $prop) {
        $propname = trim($prop);
Beispiel #5
0
<?php

require_once "../arc/ARC2.php";
require_once "../Graphite.php";
$graph = new Graphite();
$graph->ns("sr", "http://data.ordnancesurvey.co.uk/ontology/spatialrelations/");
$rd = $graph->resource("http://id.southampton.ac.uk/building/32")->prepareDescription();
$rd->addRoute('*');
$rd->addRoute('*/rdfs:label');
$rd->addRoute('*/rdf:type');
$rd->addRoute('-sr:within/rdf:type');
$rd->addRoute('-sr:within/rdfs:label');
$n = $rd->loadSPARQL("http://sparql.data.southampton.ac.uk/");
$rd->handleFormat("json");
Beispiel #6
0
#!/usr/bin/php
<?php 
# this is intended to be run on the command-line, but you could run it
# via the web if you wanted.
# you'll need to change all the paths.
require_once "../arc/ARC2.php";
require_once "../Graphite.php";
$graph = new Graphite();
$graph->ns("foo", "http://example.org/foons/");
$graph->load("mydata.rdf");
$graph->freeze("mydata.rdf.graphite");
# to use this graph from a script, use
# $graph = Graphite::thaw( "mydata.rdf.graphite" );
<?php

include_once "arc/ARC2.php";
include_once "Graphite.php";
$graph = new Graphite();
$graph->ns("org", "http://www.w3.org/ns/org#");
$uri = "http://id.southampton.ac.uk/org/F2";
$graph->load($uri);
print $graph->resource($uri)->all("org:hasSubOrganization")->sort("rdfs:label")->getString("rdfs:label")->join(", ") . ".\n";