From Protege Wiki

Jump to: navigation, search

Question: How do I import an ontology using the Protege OWL API?

The following code snippet shows how to import ontologies programmatically:

JenaOWLModel owlModel = ProtegeOWL.createJenaOWLModel();

//if you want to use a custom prefix for the namespace of the imported ontology, uncomment the following line
//owlModel.getNamespaceManager().setPrefix(new URI(""), "myPrefix");

//create the ImportHelper
ImportHelper importHelper = new ImportHelper((JenaOWLModel)owlModel);

//this is the URI from where your ontology is created 
URI importUri = URIUtilities.createURI("/tmp/importedOntology.owl");
//add the import (multiple imports can be added here)

try {
    //do the actual import
} catch (Exception e) {		
Personal tools