ARC2
From Data-gov Wiki
|
Note: this material is on its way to http://tw.rpi.edu/web/inside/endpoints/installing-arc2
Contents |
Data-gov Usage
Resources
- ARC2: http://arc.semsol.org/
- ARC2 Download: http://arc.semsol.org/download
- ARC2 Documentation: http://arc.semsol.org/docs
Sample Code
Creating a SPARQL endpoint
Supposing there is a database already created.
<?php
include_once('arc/ARC2.php');
$config = array(
/* db */
'db_host' => 'myserver',
'db_name' => 'dbname',
'db_user' => 'user',
'db_pwd' => 'pass',
/* store name */
'store_name' => 'my_endpoint_store',
/* instructinos accepted */
'endpoint_features' => array(
'select', 'construct', 'ask', 'describe',
'load', 'insert', 'delete','dump'
),
'endpoint_timeout' => 60, /* not implemented in ARC2 preview */
'endpoint_read_key' => , /* optional */
'endpoint_write_key' => , /* optional */
'endpoint_max_limit' => 0, /* optional */
);
/* instantiation */
$ep = ARC2::getStoreEndpoint($config);
/* If tables in DB does not exists, ARC will create it */
if (!$ep->isSetUp()) {
$ep->setUp(); /* create MySQL tables */
}
/* request handling */
$ep->go();
?>
Loading data from a URI
<?
include_once('arc/ARC2.php');
$parser = ARC2::getRDFXMLParser();
$parser->parse("http://inference-web.org/registry/PUB/STE.owl");
$triples = $parser->getTriples();
foreach($triples as $k => $v){
print "Subject: ".$v['s']." Predicate:".$v['p']." Object:".$v['o'];
}
?>
Exporting RDF
<?
include_once('arc/ARC2.php');
header('Content-Type: text/plain');
$aux = array();
//Subject
$aux['s'] = "http://graves.cl/foaf.rdf#me";
$aux['s_type'] = 'uri';
//Predicate
$aux['p'] = "http://xmlns.com/foaf/0.1/name";
//Object
$aux['o'] = "Alvaro Graves";
$aux['o_type'] = "literal";
$aux['o_datatype'] = "xsd:string";
$aux['o_lang'] = "es";
$triples = array();
array_push($triples, $aux);
$conf = array('ns' => array('foaf' => 'http://xmlns.com/foaf/0.1/'));
$ser = ARC2::getRDFXMLSerializer($conf);
$doc = $ser->getSerializedTriples($triples);
echo $doc;
?>
Facts about ARC2RDF feed
| Dcterms:description | a flexible RDF system for semantic web and PHP practitioners. |
| Dcterms:modified | 2011-5-5 |
| Foaf:homepage | http://arc.semsol.org/ + |
| Foaf:name | ARC2 |
| Skos:altLabel | ARC2 +, and arc2 + |

