Source for file OntModel.php
Documentation is available at OntModel.php
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
* Enhanced view of the model that is known to contain ontology data, under a
* given ontology vocabulary (such as RDFS). OntModel together with OntClass
* and OntResource provide ontology specific methods like addSubClass(),
* listSubClasses(), hasSuperProperty(), addDomain() and listInstances(). This class does not by
* itself compute the deductive extension of the graph under the semantic
* rules of the language. Instead, we wrap an underlying model with this
* ontology interface, that presents a convenience syntax for accessing the
* language elements. Depending on the inference capability of the underlying
* model, the OntModel will appear to contain more or less triples.
* For example, if this class is used to wrap a MemModel or DBModel, only the
* relationships asserted by the document will be reported through this
* Alternatively, if the OntModel wraps an InfModel (InfModelF / InfModelB),
* the inferred triples from the extension will be reported as well.
* @version $Id: fsource_ontModel__ontModelOntModel.php.html 443 2007-06-01 16:25:38Z cax $
* @author Daniel Westphal <mail at d-westphal dot de>
* Holds a reference to the assoiated vocabulary.
* You have to supply a memmodel/dbmodel/infmodel to save the statements and a vocabulary
* @param object Model $model
function OntModel(& $model,& $vocabulary)
$this->vocabulary =
& $vocabulary;
* Answer a resource that represents a class description node in this model.
* If a resource with the given uri exists in the model, it will be re-used.
* If not, a new one is created in the updateable sub-model of the ontology model.
* @return object OntClass
$class->setAssociatedModel($this);
$class->setVocabulary($this->vocabulary);
$class->setInstanceRdfType($this->vocabulary->ONTCLASS());
* Answer a resource that represents an Individual node in this model.
* If a resource with the given uri exists in the model, it will be re-used.
* If not, a new one is created in the updateable sub-model of the ontology model.
* @return object Individual
$individual->setAssociatedModel($this);
$individual->setVocabulary($this->vocabulary);
* Answer a resource that represents an OntProperty node in this model.
* If a resource with the given uri exists in the model, it will be re-used.
* If not, a new one is created in the updateable sub-model of the ontology model.
* @return object OntProperty
$ontProperty->setAssociatedModel($this);
$ontProperty->setVocabulary($this->vocabulary);
* Answer an array that ranges over all of the various forms of class
* description resource in this model.
* Class descriptions include domain/range definitions, named classes and subClass constructs.
* @return array of object ResResource
//get all statements, with an rdf:type as property
$statements=
$this->find(null,$this->vocabulary->TYPE(),null);
foreach ($statements as $statement)
$objectLabel=
$statement->getLabelObject();
//if it's about a typed Individual
if (!in_array($objectLabel,$returnIndex))
$returnIndex[]=
$objectLabel;
$return[]=
$statement->getObject();
//if it's a "class1 rdf:type rdf:class" construct
$subjectLabel=
$statement->getLabelSubject();
if (!in_array($subjectLabel,$returnIndex))
$returnIndex[]=
$subjectLabel;
$return[]=
$statement->getSubject();
//find all statements about SubClassConstructs
$statements=
$this->find(null,$this->vocabulary->SUB_CLASS_OF(),null);
foreach ($statements as $statement)
//add the statements object to the result
$objectLabel=
$statement->getLabelObject();
if (!in_array($objectLabel,$returnIndex))
$returnIndex[]=
$objectLabel;
$return[]=
$statement->getObject();
foreach ($statements as $statement)
//add the statements subject to the result
$objectLabel=
$statement->getLabelSubject();
if (!in_array($objectLabel,$returnIndex))
$returnIndex[]=
$objectLabel;
$return[]=
$statement->getSubject();
Documentation generated on Fri, 1 Jun 2007 16:50:08 +0200 by phpDocumentor 1.3.2