/** * Loop trough the jena infmodel tests */ function testRdfsFModel() { $testURI = 'http://www.hpl.hp.com/semweb/2003/query_tester#'; $testmodel = new MemModel($testURI); $testmodel->load(RDFS_INF_TESTFILES . 'rdfs/manifest-standard.rdf'); $i = 1; do { $inf = new RDFSFModel(); $res1 = $testmodel->find(new Resource(RDFS_INF_TESTFILES . 'rdfs/test' . $i++), null, null); if ($res1->isEmpty()) { break; } $findTBOX = $res1->find(null, new Resource($testURI . 'tbox'), null); $inf->load(RDFS_INF_TESTFILES . $findTBOX->triples[0]->getLabelObject()); $findDATA = $res1->find(null, new Resource($testURI . 'data'), null); $inf->load(RDFS_INF_TESTFILES . $findDATA->triples[0]->getLabelObject()); $findQUERY = $res1->find(null, new Resource($testURI . 'query'), null); $query = $this->_doFindFromFile(RDFS_INF_TESTFILES . $findQUERY->triples[0]->getLabelObject(), $inf); $result = new MemModel(); $findRESULT = $res1->find(null, new Resource($testURI . 'result'), null); $result->load(RDFS_INF_TESTFILES . $findRESULT->triples[0]->getLabelObject()); $isEqual = $result->equals($query); #$query->writeAsHtmlTable(); #$result->writeAsHtmlTable(); #$subtract=$query->subtract($result); #$subtract->writeAsHtmlTable(); $findDATA = $res1->find(null, new Resource($testURI . 'description'), null); echo '<b>' . $findDATA->triples[0]->getLabelObject() . ' (RDFSFModel)</b><BR>'; $this->assertTrue($isEqual); } while (true); }
$model = new MemModel(); // Load and parse document $model->load($base); // Output model as HTML table $model->writeAsHtmlTable(); echo "<P>"; // Ceate new statements and add them to the model $statement1 = new Statement(new Resource("http://www.w3.org/Home/Lassila"), new Resource("http://description.org/schema/Description"), new Literal("Lassila's personal Homepage", "en")); $statement2 = new Statement(new Resource("http://www.w3.org/Home/Lassila"), new Resource("http://description.org/schema/Description"), new Literal("Lassilas persönliche Homepage ", "de")); $model->add($statement1); $model->add($statement2); $model->writeAsHtmlTable(); echo "<P>"; // Search model 1 $homepage = new Resource("http://www.w3.org/Home/Lassila"); $res = $model->find($homepage, NULL, NULL); $res->writeAsHtmlTable(); echo "<P>"; // Search model 2 $description = new Resource("http://description.org/schema/Description"); $statement = $model->findFirstMatchingStatement($homepage, $description, NULL); // Check if something was found and output result if ($statement) { echo $statement->toString(); } else { echo "Sorry, I didn't find anything."; } echo "<P>"; // Search model 3 $res3 = $model->findVocabulary("http://example.org/stuff/1.0/"); $res3->writeAsHtmlTable();