tags:

views:

39

answers:

2

How can I get an existent Class from an Ontology with owlAPI?

This is a fragment of my ontology:

...
  <owl:Class rdf:ID="StringDocu">
    <owl:equivalentClass>
      <owl:Restriction>
        <owl:someValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/&gt;
        <owl:onProperty rdf:resource="#hasContent"/>
      </owl:Restriction>
    </owl:equivalentClass>
    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >String Docu</rdfs:label>
    <rdfs:subClassOf rdf:resource="#Docu"/>
    <owl:disjointWith rdf:resource="#URIDocu"/>
    <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >This class concerns a docu with the content specified as common text.</rdfs:comment>
  </owl:Class>
...

I start whit this code:

String ontologyUri = "http://mysite.com/my_ontology.owl";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.createOntology(IRI.create(ontologyUri));
OWLDataFactory factory = manager.getOWLDataFactory();

and now I want to retrieve the "StringDocu" class. How can I get this?

A: 

please help this poor boy!!!!!

enrico
A: 

I think this will give you all classes referenced in the ontology you loaded:

String ontologyUri = "http://mysite.com/my_ontology.owl";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.createOntology(IRI.create(ontologyUri));
Set <OWLClass> classes = ontology.getClassesInSignature();

Then you can process/filter/find whatever you need on that set of OWLClass.

wongiseng