ProtegeOWL API Programmers Guide

From Protege Wiki

Jump to: navigation, search

Protege-OWL API Programmer's Guide

The Protege-OWL API is an open-source Java library for the Web Ontology Language (OWL) and RDF(S). The API provides classes and methods to load and save OWL files, to query and manipulate OWL data models, and to perform reasoning based on Description Logic engines. Furthermore, the API is optimized for the implementation of graphical user interfaces.

- Original Author: Holger Knublauch
- Currently maintained by: Protege staff members (contributions from the user community are welcome)
- Last update: June 30, 2010


Contents


Overview

The Protege-OWL API is an open-source Java library for the Web Ontology Language (OWL) and RDF(S). The API provides classes and methods to load and save OWL files, to query and manipulate OWL data models, and to perform reasoning based on Description Logic engines. Furthermore, the API is optimized for the implementation of graphical user interfaces.

The API is designed to be used in two contexts:

  • For the development of components that are executed inside of the Protege-OWL editor's user interface
  • For the development of stand-alone applications (e.g., Swing applications, Servlets, or Eclipse plug-ins)

Protege is a flexible, configurable platform for the development of arbitrary model-driven applications and components. Protege has an open architecture that allows programmers to integrate plug-ins, which can appear as separate tabs, specific user interface components (widgets), or perform any other task on the current model. The Protege-OWL editor provides many editing and browsing facilities for OWL models, and therefore can serve as an attractive starting point for rapid application development. Developers can initially wrap their components into a Protege tab widget and later extract them to distribute them as part of a stand-alone application.

This guide will introduce you to some basic concepts of the Protege-OWL API, no matter whether you intend to use it for stand-alone applications or Protege plug-ins. The guide tries to illustrate the API by examples, and most examples create parts of OWL ontologies such as properties and restrictions. The complete source code for most of the examples can be found in the edu.stanford.smi.protegex.owlx.examples package in the Protege-OWL source code. If you have trouble getting started, please post questions on the protege-owl mailing list.

Installation & Getting Started

The Protege-OWL editor is provided with the standard installation of Protege. In addition to installing Protege, you should download the source code from the Protege Subversion repository. The source code is the most reliable reference for the system's functionality and browsing the source code with a Java IDE is a great way to learn the API. Detailed instructions on how to download source code from our repository are available on the main Protege website. The URL to download the Protege-OWL source code using a Subversion client is:

http://smi-protege.stanford.edu/repos/protege/owl/trunk/.

You will also find Javadoc for the API useful. In particular, you will need to understand the interfaces from the edu.stanford.smi.protegex.owl.model package.

Following a successful installation, your directory structure should look approximately as follows:

Directory structure of the Protege application after a successful install

Now let us configure our Java project and write a small "Hello World" application. If you are using a Java IDE such as Eclipse or IntelliJ, select the Protege installation folder as your project home. Next, add all the JAR files from the installation to your project classpath. Set your compiler output path to plugins/classes.

Then create a Java class such as the following:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

Execute this program stand-alone. The output should be "Class URI: http://hello.com#World".


Basics

For more details on this topic, see Protege-OWL API Basics

Covered topics include:

  • Working with OWL Models
  • Names, Namespace prefixes, and URIs
  • Understanding the Model Interfaces
  • Creating Named Classes and Individuals
  • Using Datatype Properties and Datatype Values
  • Using Object Properties to Build Relationships between Resources
  • Working with References to External/Untyped Resources
  • Property Domains


Advanced Class Definitions (OWL DL)

For more details on this topic, see Protege-OWL API Advanced Class Definitions (OWL DL)

Covered topics include:

  • Restrictions
  • Logical Class Definitions (Unions, Intersections, Complements)
  • Enumerated Classes
  • Creating Defined Classes


Advanced Topics

For more details on this topic, see Protege-OWL API Advanced Topics

Covered topics include:

  • Querying the OWLModel
  • RDF(S) and OWL
  • Reacting to Changes using Listeners
  • Loading and Saving Files
  • Working with Multi-File Projects and TripleStores
  • Working with Jena Models


Protege Programming

For more details on this topic, see Programming with Protege-OWL

Covered topics include:

  • Protege-OWL and the Core Protege API
  • Changes from the old Protege-OWL API
  • Protege User Interface Programming
  • Protege Plug-in Development


Building Semantic Web Applications

For more details on this topic, see Building Semantic Web Applications

This section provides information on building standalone Semantic Web applications using the Protege-OWL API.

Personal tools