From: Richard C. <ri...@cy...> - 2006-03-02 01:58:35
|
Hi Charles, Apologies, I misread your code. Details below. On 1 Mar 2006, at 23:44, Charles Nepote wrote: > I tried the getOntModelForBaseModel method with a fresh CVS. But I =20 > still have an error... here is my code for tests : > > <?php > > define("RDFAPI_INCLUDE_DIR", "/var/www/wikisem/rdfapi-php/api/"); > include(RDFAPI_INCLUDE_DIR . "RdfAPI.php"); > include("/var/www/wiki-s/config.inc.php"); > > > $wiki =3D new Wiki($config); > > > Class Wiki > { > function Wiki($config) > { > $store =3D ModelFactory::getDbStore( > $config['db_engine'], > $config['db_server'], > $config['db_database'], > $config['db_user'], > $config['db_password']); > $this->dbModel =3D = $store->getModel('http://rn7.net/2006/02/07'); > $this->dbModel->writeAsHtmlTable(); // To verify if the = model is =20 > correctly loaded > $this->ontModel =3D = ModelFactory::getOntModelForBaseModel($this-=20 > >dbModel, RDFS_VOCABULARY); That's OK, but the original version should work now as well: $this->ontModel =3D $this->dbModel->getOntModel(RDFS_VOCABULARY); > =09 > $test =3D new = OntResource("http://www.w3.org/1999/02/22-rdf-syntax-=20 > ns#type"); Here's the problem. You're not supposed to create OntResources =20 directly. Use the $ontModel->createXXX() methods instead. $test =3D $this->ontModel->createOntProperty("http://www.w3.org/=20 1999/02/22-rdf-syntax-ns#type"); > $sup =3D $test->listRDFTypes(); Then you can do: foreach($sup as $type) { echo $type->getURI(); } Output for me is: http://www.w3.org/1999/02/22-rdf-syntax-ns#Property. Sorry again. Richard > } > =09 > } > > ?> > > The model is correctly loaded from the base and a HTML table of 329 =20= > lines is correctly displayed. There are plenty of rdf:type in the =20 > model ; so listRDFTypes should give an answer... Instead I get a : > > Fatal error: Call to a member function on a non-object in /var/www/=20 > wikisem/rdfapi-cvs/rdfapi-php/api/ontModel/OntResource.php on line 402 > > Is my syntax for creating the OntModem correct ? > > Charles N=E9pote. > |