user2083783
user2083783

Reputation: 31

Creating an OWL ontology that imports other ontologies with OWL-API

I have just started using the OWL API in order to generate some examples that use other ontologies. The situation is like this: I have two ontologies A and B that have many elements and imports from other ontologies. These two ontologies are part of a standard so they are closely related. I need to generate an example of the standard's element that involves importing this two ontologies and using and combining classes and elements from both, but I don't know how to start. I have tried using the API but the only I have achieved is loading one of the ontologies, taking some classes and properties and combining them into a new ontology. I also don't know how to define some namespace imports and some ontologies imports. Also, I don't know how to define some shortcuts to use short namespaces instead of the large ones. How can I do this?

Upvotes: 2

Views: 1234

Answers (2)

sysoutkoula
sysoutkoula

Reputation: 340

You could add a prefix using PrefixOWLOntologyFormat

PrefixOWLOntologyFormat pf = (PrefixOWLOntologyFormat) manager.getOntologyFormat(ontology);
pf.setPrefix("aprefix" , "http://someurl/a.owl");

Upvotes: 1

casualcoder
casualcoder

Reputation: 500

I don't know how you built your ontologies, but I suggest you add a namespace for the imported ontologies.

You can either do this in Protege by generating a prefix mapping in the "Ontology Prefixes" tab on the bottom of the "Active Ontology Tab" or manually in a text editor of your choice by adding a line like:

<Prefix name="your_desired_prefix" IRI="http://www.your.ontology/abc/xyz#"/>

Once you've done that, you can get hold of classes or individuals from different ontologies by using the namespace you defined. In Java using the OWLAPI this would look something like:

OWLClass yourClass = factory.getOWLClass("your_desired_prefix:Classname", pm);

I hope this is what you were looking for.

Upvotes: 0

Related Questions