<?php 

//change the RDFAPI_INCLUDE_DIR to your local settings
define("RDFAPI_INCLUDE_DIR", "C:/!htdocs/rdfapi-php/api/"); 
include(RDFAPI_INCLUDE_DIR . "RdfAPI.php");

//create a InfmodelF
$infModel= ModelFactory::getInfModelF('http://InfModelF.org');

//add new statements
$infModel->add(new Statement(new Resource('http://example.org/baz1'),new Resource('http://example.org/bat'),new Resource('http://example.org/baz2')));
$infModel->add(new Statement(new Resource('http://example.org/bat'),new Resource('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'),new Resource('http://example.org/bas')));

echo '<B>Added the following Triples:</B><BR>'.htmlentities('
<http://example.org/baz1> <http://example.org/bat> <http://example.org/baz2> .').'<BR>'.htmlentities('
<http://example.org/bat> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/bas> .
').'<BR>';

//output the model as HTML table
$infModel->writeAsHtmlTable();
echo '<BR><hr><BR>';



$infModel->add(new Statement(new Resource('http://example.org/bat'),new Resource('http://www.w3.org/2000/01/rdf-schema#domain'),new Resource('http://example.org/Domain1')));
$infModel->add(new Statement(new Resource('http://example.org/bat'),new Resource('http://www.w3.org/2000/01/rdf-schema#range'),new Resource('http://example.org/Range1')));

echo '<B>Added the following Triples:</B><BR>'.htmlentities('
<http://example.org/bat> <http://www.w3.org/2000/01/rdf-schema#domain> <http://example.org/Domain1> .').'<BR>'.htmlentities('
<http://example.org/bat> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.org/Range1> .
').'<BR>';
$infModel->writeAsHtmlTable();
echo '<BR><hr><BR>';




$infModel->add(new Statement(new Resource('http://example.org/bas'),new Resource('http://www.w3.org/2000/01/rdf-schema#domain'),new Resource('http://example.org/Domain2')));
$infModel->add(new Statement(new Resource('http://example.org/bas'),new Resource('http://www.w3.org/2000/01/rdf-schema#range'),new Resource('http://example.org/Range2')));

echo '<B>Added the following Triples :</B><BR>'.htmlentities('
<http://example.org/bas> <http://www.w3.org/2000/01/rdf-schema#domain> <http://example.org/Domain2> .').'<BR>'.htmlentities('
<http://example.org/bas> <http://www.w3.org/2000/01/rdf-schema#range> <http://example.org/Range2> .
').'<BR>';
$infModel->writeAsHtmlTable();
echo '<BR><hr><BR>';


$infModel->add(new Statement(new Resource('http://example.org/Domain2'),new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'),new Resource('http://example.org/Domain3')));
$infModel->add(new Statement(new Resource('http://example.org/Domain3'),new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'),new Resource('http://example.org/Domain2')));

echo '<B>Added the following Triples (loop in the ontology) :</B><BR>'.htmlentities('
<http://example.org/Domain2> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/Domain3> .').'<BR>'.htmlentities('
<http://example.org/Domain3> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/Domain2> .');
$infModel->writeAsHtmlTable();
echo '<BR><hr><BR>';



$infModel->add(new Statement(new Resource('http://example.org/Range3'),new Resource('http://www.w3.org/2002/07/owl#sameAs'),new Resource('http://example.org/Range2')));
$infModel->add(new Statement(new Resource('http://example.org/Range3'),new Resource('http://www.w3.org/2002/07/owl#sameAs'),new Resource('http://example.org/Range2')));

echo '<B>Added the following Triple :</B><BR>'.htmlentities('
<http://example.org/Range3> <http://www.w3.org/2002/07/owl#sameAs> <http://example.org/Range2> .').'<BR>';
$infModel->writeAsHtmlTable();
echo '<BR><hr><BR>';



$findResult=$infModel->find(new Resource('http://example.org/baz1'),null,null);
echo '<B>Perform a find(http://example.org/baz1,null,null) :</B><BR>';
$findResult->writeAsHtmlTable();
echo '<BR><hr><BR>';



$infModel->remove(new Statement(new Resource('http://example.org/bat'),new Resource('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'),new Resource('http://example.org/bas')));

echo '<B>Removed the following Triple :</B><BR>'.htmlentities('
<http://example.org/bat> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/bas> .').'<BR>';
$infModel->writeAsHtmlTable();

?>