Difference between revisions of "ImportUsingProtegeOWLAPI"
From Protege Wiki
(moved content from old wiki to this new page on new wiki) |
(categorizing page) |
||
Line 26: | Line 26: | ||
... | ... | ||
</pre> | </pre> | ||
+ | |||
+ | [[Category:Protege Developer Documentation]] | ||
+ | [[Category:Protege 3 Documentation]] | ||
+ | [[Category:Protege-OWL Documentation]] |
Revision as of 15:57, May 22, 2008
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("http://a.com/myOntologies.owl#"), "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) importHelper.addImport(importUri); try { //do the actual import importHelper.importOntologies(false); } catch (Exception e) { e.printStackTrace(); } ...