Documentation

Note: this page is here for historical and sentimental reasons.

Find the updated documentation here.

Javadoc for the API may be found included in the release

Many requests have come in for the online javadoc to be updated - now at release 3.4.3

In order to use the API in your own applications, you should download the latest binary release and ensure that all of the jar files are in the application class path.

Note: the latest OWL API requires Java 6 or newer. It has been compiled and tested on Oracle JDK 7 - we have no reports on it not working on other versions of the JDK, so if you find it not working on any JRE 6 or newer, please let us know in the bug section.

If you want to check out the source code and build the binaries yourself, you can either use ANT (build file is in the antbuild folder) or Maven. Maven is the build system currently used for official builds, and it includes OSGI compatibility in the builds (experimental feature).

The central point of access is the OWLOntologyManager, which is used to load, create and access ontologies. The examples below show how to create an instance of this class and how to use it.

Code examples

  • Examples include:
  • - How to load an ontology
  • - How to save an ontology
  • - How to obtain references to entities (classes, properties, individuals etc.)
  • - How to work with data types and other data ranges
  • - How to work with user defined data ranges (e.g. int > 10)
  • - How to work with string, data values and language tags
  • - How to create an empty ontology, add axioms and save
  • - How to specify that an individual is an instance of a class
  • - How to specify that two individuals are related to each other.
  • - How to add an object property assertion (triple) to an ontology
  • - How to delete entities (classes, properties and individuals) from an ontology
  • - How to create restrictions and ''add them to classes'' as superclasses
  • - How to create an ontology and add some rules
  • - How to interact with a reasoner
  • - How to collect the properties that are used in restrictions on a given class
  • - How to work with annotations such as labels and comments
  • - How to save inferred axioms into a new ontology, or back into an existing ontology
  • - How two (or more) ontologies can be merged in a simple way
  • - How to 'walk' over the asserted structure of an ontology.
  • - How to use OWLOntologyIRIMappers to redirect loading and loading of imports.
  • - How to extract a locality based module from an ontology.

Programming with the OWL API Tutorial

Note: most of the API has changed since this tutorial was written (2007). The theoretical basis is, however, the same. If you are new to OWL, start with this.

A set of tutorial slides are available below. Some simple examples that relate to the tutorial slides are provided. These illustrate parsing ontologies from concrete formats; rendering to concrete formats; manipulating ontologies and using inference services. If you check out the OWL API source code from the sourceforge website, the tutorial examples can be found in the tutorial directory.

Slides

Slides are available in PDF format:

Code examples

Simple Hierarchy

This example shows how we can calculate and display a basic ontology hierarchy. The example makes use of an OWLReasoner to calculate the class hierarchy, then navigates the structure obtained, printing out basic information for each of the classes.

The example either uses a StructuralReasoner, which returns information about the hierarchy based solely on the assertions that are made in the ontology.

Rendering example

This example shows the definition of a simple renderer. The renderer provided an HTML page describing the entities in the ontology.

Closure Axioms

This example illustrates manipulation of axioms in an ontology.

Debugging

This example illustrates the use of the debugger. The debugger identifies axioms causing inconsistencies in OWL ontologies.

Name Changes from OWL API 2 to OWL API 3

Version 3 of the OWL API is backward incompatible with version 2 of the OWL API. The reason for this is that it was decided to align the names of interfaces with the names used in the OWL 2 Structural Specification. The main API interfaces and corresponding name changes are shown in the table below. It should be noted that the URI class has been replaces with the IRI class. Additionally, package names have changed. In general, replace "owl" with "owlapi" in client code to rename OWL API 2 package names to OWL API 3 package names. For example, org.semanticweb.owl.model has become org.semanticweb.owlapi.model.

OWL API 2 Interface OWL API 3 Interface
AddAxiom
AxiomType
DataRangeType DatarangeType
DefaultChangeBroadcastStrategy
DescriptionType ClassExpressionType
ImmutableOWLOntologyChangeException
MissingImportEvent
MissingImportListener
NamespaceManager PrefixManager
OWLAnnotation
OWLAnnotationAxiom
OWLAnnotationVisitor
OWLAnnotationVisitorEx
OWLAnonymousDescription OWLAnonymousClassExpression
OWLAnonymousIndividual
OWLAntiSymmetricObjectPropertyAxiom OWLAsymmetricObjectPropertyAxiom
OWLAxiom
OWLAxiomAnnotationAxiom
OWLAxiomChange
OWLAxiomVisitor
OWLAxiomVisitorEx
OWLBooleanDescription OWLBooleanClassExpression
OWLCardinalityRestriction
OWLClass
OWLClassAssertionAxiom
OWLClassAxiom
OWLCommentAnnotation Use an annotation with rdfs:comment as the property
OWLCompositeOntologyChange
OWLConstant OWLLiteral
OWLConstantAnnotation
OWLDataAllRestriction OWLDataAllValuesFrom
OWLDataCardinalityRestriction
OWLDataComplementOf
OWLDataExactCardinalityRestriction OWLDataExactCardinality
OWLDataFactory
OWLDataMaxCardinalityRestriction OWLDataMaxCardinality
OWLDataMinCardinalityRestriction OWLDataMinCardinality
OWLDataOneOf
OWLDataProperty
OWLDataPropertyAssertionAxiom
OWLDataPropertyAxiom
OWLDataPropertyCharacteristicAxiom
OWLDataPropertyDomainAxiom
OWLDataPropertyExpression
OWLDataPropertyRangeAxiom
OWLDataRange
OWLDataRangeFacetRestriction OWLFacetRestriction
OWLDataRangeRestriction OWLDatatypeRestriction
OWLDataSomeRestriction OWLDataSomeValiesFrom
OWLDataSubPropertyAxiom OWLSubDataPropertyOfAxiom
OWLDataType OWLDatatype
OWLDataValueRestriction OWLDataHasValue
OWLDataVisitor
OWLDataVisitorEx
OWLDeclarationAxiom
OWLDeprecatedClassAxiom Deprecation on IRIs is done using a built in annotation
OWLDeprecatedDataPropertyAxiom Deprecation on IRIs is done using a built in annotation
OWLDeprecatedObjectPropertyAxiom Deprecation on IRIs is done using a built in annotation
OWLDescription OWLClassExpression
OWLDescriptionVisitor OWLClassExpressionVisitor
OWLDescriptionVisitorEx OWLClassExpressionVisitorEx
OWLDifferentIndividualsAxiom
OWLDisjointClassesAxiom
OWLDisjointDataPropertiesAxiom
OWLDisjointObjectPropertiesAxiom
OWLDisjointUnionAxiom
OWLEntity
OWLEntityAnnotationAxiom OWLAnnotationAssertionAxiom
OWLEntityVisitor
OWLEntityVisitorEx
OWLEquivalentClassesAxiom
OWLEquivalentDataPropertiesAxiom
OWLEquivalentObjectPropertiesAxiom
OWLException
OWLFunctionalDataPropertyAxiom
OWLFunctionalObjectPropertyAxiom
OWLImportsDeclaration This is no longer an axiom
OWLIndividual OWLNamedIndividual
OWLIndividualAxiom
OWLInverseFunctionalObjectPropertyAxiom
OWLInverseObjectPropertiesAxiom
OWLIrreflexiveObjectPropertyAxiom
OWLLabelAnnotation Use an annotation with rdfs:label as the property
OWLLogicalAxiom
OWLMutableOntology
OWLNamedObject
OWLNamedObjectVisitor
OWLNamedObjectVisitorEx
OWLNaryBooleanDescription OWLNaryBooleanClassExpression
OWLNaryClassAxiom
OWLNaryIndividualAxiom
OWLNaryPropertyAxiom
OWLNegativeDataPropertyAssertionAxiom
OWLNegativeObjectPropertyAssertionAxiom
OWLObject
OWLObjectAllRestriction OWLObjectAllValuesFrom
OWLObjectAnnotation
OWLObjectCardinalityRestriction
OWLObjectComplementOf
OWLObjectExactCardinalityRestriction OWLObjectExactCardinality
OWLObjectIntersectionOf
OWLObjectMaxCardinalityRestriction OWLObjectMaxCardinality
OWLObjectMinCardinalityRestriction OWLObjectMinCardinality
OWLObjectOneOf
OWLObjectProperty
OWLObjectPropertyAssertionAxiom
OWLObjectPropertyAxiom
OWLObjectPropertyChainSubPropertyAxiom OWLSubPropertyChainOfAxiom
OWLObjectPropertyCharacteristicAxiom
OWLObjectPropertyDomainAxiom
OWLObjectPropertyExpression
OWLObjectPropertyInverse
OWLObjectPropertyRangeAxiom
OWLObjectSelfRestriction OWLObjectHasSelf
OWLObjectSomeRestriction OWLObjectSomeValuesFrom
OWLObjectSubPropertyAxiom OWLSubObjectPropertyOfAxiom
OWLObjectUnionOf
OWLObjectValueRestriction OWLObjectHasValue
OWLObjectVisitor
OWLObjectVisitorEx
OWLOntology
OWLOntologyAnnotationAxiom Ontology annotations are now stored directly in an ontology and not as axioms in an ontology
OWLOntologyChange
OWLOntologyChangeBroadcastStrategy
OWLOntologyChangeException
OWLOntologyChangeListener
OWLOntologyChangeVetoException
OWLOntologyChangeVisitor
OWLOntologyCreationException
OWLOntologyFactory
OWLOntologyFactoryNotFoundException
OWLOntologyFormat
OWLOntologyLoaderListener
OWLOntologyManager
OWLOntologyManagerProperties
OWLOntologyResourceAccessException
OWLOntologySetProvider
OWLOntologyStorageException
OWLOntologyStorer
OWLOntologyStorerNotFoundException
OWLOntologyURIMapper OWLOntologyIRIMapper
OWLOntologyURIMappingNotFoundException OWLOntologyIRIMappingNotFoundException
OWLProperty
OWLPropertyAssertionAxiom
OWLPropertyAxiom
OWLPropertyDomainAxiom
OWLPropertyExpression
OWLPropertyExpressionVisitor
OWLPropertyExpressionVisitorEx
OWLPropertyRange
OWLPropertyRangeAxiom
OWLQuantifiedRestriction
OWLReflexiveObjectPropertyAxiom
OWLRestriction
OWLRuntimeException
OWLSameIndividualsAxiom OWLSameIndividualAxiom
OWLSubClassAxiom OWLSubClassOfAxiom
OWLSubPropertyAxiom OWLSubPropertyOfAxiom
OWLSymmetricObjectPropertyAxiom
OWLTransitiveObjectPropertyAxiom
OWLTypedConstant OWLTypedLiteral
OWLUnaryPropertyAxiom
OWLUntypedConstant OWLStringLiteral
OWLValueRestriction OWLHasValueRestriction
RemoveAxiom
SWRLAtom
SWRLAtomConstantObject SWRLLiteralArgument
SWRLAtomDObject SWRLDArgument
SWRLAtomDVariable SWRLVariable
SWRLAtomIObject SWRLObjectArgument
SWRLAtomIVariable SWRLVariable
SWRLAtomIndividualObject SWRLIndividualArgument
SWRLAtomObject SWRLArgument
SWRLAtomVariable SWRLVariable
SWRLBinaryAtom
SWRLBuiltInAtom
SWRLClassAtom
SWRLDataFactory
SWRLDataRangeAtom
SWRLDataValuedPropertyAtom SWRLDataPropertyAtom
SWRLDifferentFromAtom SWRLDifferentIndividualsAtom
SWRLObject
SWRLObjectPropertyAtom
SWRLObjectVisitor
SWRLObjectVisitorEx
SWRLRule
SWRLSameAsAtom SWRLSameIndividualAtom
SWRLUnaryAtom
SetOntologyURI SetOntologyID
SpecificOntologyChangeBroadcastStrategy
MonitorableOWLReasoner Set an OWLReasonerProgressMonitor in the reasoner configuration at reasoner creation time
MonitorableOWLReasonerAdapter
NullReasoner
NullReasonerFactory
OWLClassReasoner OWLReasoner
OWLConsistencyChecker OWLReasoner
OWLInconsistentOntologyException
OWLIndividualReasoner OWLReasoner
OWLPropertyReasoner OWLReasoner
OWLReasoner
OWLReasonerAdapter OWLReasoner
OWLReasonerBase OWLReasoner
OWLReasonerException
OWLReasonerFactory
OWLReasonerManager
OWLReasonerManagerEvent
OWLReasonerManagerImpl
OWLReasonerManagerListener
OWLSatisfiabilityChecker OWLReasoner
UndefinedEntityException
UnsupportedReasonerOperationException