コード例 #1
0
 public function testReplaceHttpError()
 {
     $data = "<urn:subject> <urn:predicate> \"object\" .\n";
     $this->client->addMock('PUT', '/data/existing.rdf', 'Internal Server Error', array('status' => 500));
     $this->setExpectedException('EasyRdf_Exception', 'HTTP request for http://localhost:8080/data/existing.rdf failed');
     $response = $this->graphStore->replace($data, 'existing.rdf');
 }
コード例 #2
0
// Load the parsers and serialisers that we are going to use
# FIXME: better way to do this?
$autoloader->autoload('EasyRdf_Serialiser_Ntriples');
$autoloader->autoload('EasyRdf_Parser_Ntriples');
?>

<html>
<head>
  <title>Zend Framework Example</title>
</head>
<body>
<h1>Zend Framework Example</h1>

<?php 
# Load some sample data into a graph
$graph = new EasyRdf_Graph('http://example.com/joe');
$joe = $graph->resource('http://example.com/joe#me', 'foaf:Person');
$joe->add('foaf:name', 'Joe Bloggs');
$joe->addResource('foaf:homepage', 'http://example.com/joe/');
# Store it in a local graphstore
$store = new EasyRdf_GraphStore('http://localhost:8080/data/');
$store->replace($graph);
# Now make a query to the graphstore
$sparql = new EasyRdf_Sparql_Client('http://localhost:8080/sparql/');
$result = $sparql->query('SELECT * WHERE {<http://example.com/joe#me> ?p ?o}');
echo $result->dump();
?>

</body>
</html>
コード例 #3
0
 * running on your local machine in order to test this example.
 *
 * @package    EasyRdf
 * @copyright  Copyright (c) 2009-2011 Nicholas J Humfrey
 * @license    http://unlicense.org/
 */
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
?>
<html>
<head>
  <title>GraphStore example</title>
</head>
<body>

<?php 
// Use a local SPARQL 1.1 Graph Store (eg RedStore)
$gs = new EasyRdf_GraphStore('http://localhost:8080/data/');
// Add the current time in a graph
$graph1 = new EasyRdf_Graph();
$graph1->add('http://example.com/test', 'rdfs:label', 'Test');
$graph1->add('http://example.com/test', 'dc:date', time());
$gs->insert($graph1, 'time.rdf');
// Get the graph back out of the graph store and display it
$graph2 = $gs->get('time.rdf');
print $graph2->dump();
?>

</body>
</html>