EODM Documentation

1.0.0

 

 

 

September 2006

 

 

Contributors:

IBM: initial documentation

 

 

 

 

 

 

 

Copyrights:

Copyright © 2004-2006 IBM Corporation

 

Licensed under Eclipse Public License Version 1.0

Table of Contents

Introduction. 3

What is EODM.. 3

Components of EODM.. 3

EODM User Guide, Tutorial and Examples. 4

Description of Important Packages. 4

Creating a simple OWL model 4

Navigate an OWL ontology. 6

Save OWL ontology to file. 6

Load OWL ontology from file. 7

Reuse existing models in other modeling languages. 7

Inference with EODM Reasoner 8

Example Code. 9

EODM Basic Workbench Tutorial 10

RDFS/OWL Basic Editing. 10

 


Introduction

What is EODM

EODM (EMF Ontology Definition Metamodel) is built on top of EMF and conforms to the ODM(Ontology Definition Metamodel) standard of OMG(www.OMG.org). It provides a set of programming APIs for programmers and IT specialists. User can create, modify, and navigate RDF/OWL models using EODM, just like other programming implementations of semantic models (such as Jena).

 

Compared with others tools, the most important differentiation of EODM is that all ontology objects are also EMF model objects which gives EODM the interoperability between RDF/OWL model with other EMF supported models, including models defined using XML Schema, Rational Rose, and annotated Java classes. All these will enable Semantic Web Application developers to develop ontologies using their favorite building tools, import them into EMF, and utilize the comprehensive development facility of Eclipse and EMF. EODM includes transformers to transform between Ecore and RDF/OWL. It also facilitates other tools to treat RDF/OWL ontology models as a EMF model and process and store them as usual.

Components of EODM

EODM includes 5 main components: EODM Model, EODM RDF/OWL Parser, EODM RDF/OWL Reasoner, EODM Transformer and EODM Basic Workbench in Eclipse.

EODM User Guide, Tutorial and Examples

Description of Important Packages

* org.eclipse.eodm.rdfs / org.eclipse.eodm.rdfs.impl

   interface of RDFS Model / implementaion of RDFS Model

* org.eclipse.eodm.owl / org.eclipse.eodm.owl.impl

   interface of OWL Model / implementation of OWL Model

* org.eclipse.eodm.rdf.resource.parser / org.eclipse.eodm.owl.resource.parser

   EODM RDF Parser / EODM OWL Parser

* org.eclipse.eodm.rdfs.reasoner / org.eclipse.eodm.rdfs.reasoner.impl

   EODM RDF Reasoner Interface & Implementation

* org.eclipse.eodm.owl.reasoner / org.eclipse.eodm.owl.reasoner.structural /

   org.eclipse.eodm.owl.reasoner.simple

   EODM OWL Reasoner Interface and serveral Implementations

* org.eclipse.eodm.rdfs.transformer.ecore / org.eclipse.eodm.owl.transformer.ecore

   EODM Transformation with Ecore.

  

Creating a simple OWL model

We will start from the the basics: creating an OWL model and adding OWL classes and properties into it. The example will show how to create a simple OWL ontology by using EODM API.

Fig 1

 

In this simple example, we will create a simple ontology about person. As illustrated in Figure 1, we will create an OWL class "Person" with two attributes: "name" and "age"; "Employee" is subclass of "Person", which is defined as someone who works for some organization¡­

 

In EODM, all the OWL resources are created through OWLFactory. In the example, we will firstly create an empty ontology by calling OWLFactory.createOWLOntology(). When the ontology is created, OWL reasoures can be created by calling relevant methods of OWLFactory, as shown in Table 1.

 

// obtain the OWL factory and create the ontology

OWLFactory factory = OWLFactory.eINSTANCE;

ontology = factory.createOWLOntology();       

 

//create a namespace and set it as namespace of the ontology

Namespace testNS = RDFSFactory.eINSTANCE.createNamespace(ontology,"test","http://test.org/test#");

ontology.setNamespace(testNS);

 

// create owl classes

OWLClass Person = factory.createOWLClass(ontology,"Person");

OWLClass Employee = factory.createOWLClass(ontology,"Employee");

OWLClass PersonWithHobby = factory.createOWLClass(ontology," PersonWithHobby");

OWLClass BaseballFan = factory.createOWLClass(ontology," BaseballFan");

OWLClass Org = factory.createOWLClass(ontology,"Organization");

OWLClass Hobby = factory.createOWLClass(ontology,"Hobby");

 

// define elements for Hobby

Individual basketball = factory.createIndividual(ontology,"BasketBall", Hobby);

Individual baseball = factory.createIndividual(ontology,"BaseBall", Hobby);

Individual swimming = factory.createIndividual(ontology,"Swimming", Hobby);

 

// create object properties & define their domain/range

OWLObjectProperty worksFor = factory.createOWLObjectProperty(ontology,"worksFor", Person, Org);

OWLObjectProperty like = factory.createOWLObjectProperty(ontology,"like", Person, Hobby);

 

// create datatype properties & define their domain/range

Namespace XSDNS = RDFSFactory.eINSTANCE.createNamespace(ontology,
XSD.SHORTNAME, XSD.NAMESPACE); 

RDFSDatatype XSDINT = RDFSFactory.eINSTANCE.createRDFSDatatype(ontology,XSD.sxint, XSDNS);

RDFSDatatype XSDSTR = RDFSFactory.eINSTANCE.createRDFSDatatype(ontology,XSD.sxstring, XSDNS);

OWLDatatypeProperty name = factory.createOWLDatatypeProperty(ontology,"name", Person, XSDSTR);

OWLDatatypeProperty age = factory.createOWLDatatypeProperty(ontology,"age", Person, XSDINT);

 

// build up relationship between owl classes

HasValueRestriction Restriction1 = factory.createHasValueRestriction(ontology, like, basketball);

BaseballFan.getRDFSSubClassOf().add(Person);

BaseballFan.getRDFSSubClassOf().add(Restriction1);

SomeValueFromRestriction Restriction2 = factory.createSomeValueFromRestriction(ontology, worksFor, Org);

Employee.getRDFSSubClassOf().add(Person);

Employee.getRDFSSubClassOf().add(Restriction2);

SomeValueFromRestriction Restriction3 = factory.createSomeValueFromRestriction(ontology, like, Hobby);

PeopleWithHobby.getRDFSSubClassOf().add(Person);

PeopleWithHobby.getRDFSSubClassOf().add(Restriction3);

 

// create individuals for OWL class

Individual john = factory.createIndividual(ontology,"John", Person);

Individual andy = factory.createIndividual(ontology,"Andy ", BaseballFan);

 

Table 1 Creating an ontology to describe person

Navigate an OWL ontology

To navigate an OWL ontology, it is primarily through the Ontology interface and OWL resource interface. For example, to get all instances of OWLClass "Person", we can firstly call the Ontology.getContainedResource (Namespace namespace, String localName) to retrieve a reference of the OWLClass "Person" in Ontology. And then the instances of "Person" can be retrieved by calling the getInstance() method of "Person". Table 2 shows a list of codes of how to navigate an ontology.

 

(Note: the return results only include those declared facts, which means it will not return any results by inference)

 

// get sub class of an OWL class

OWLClass person = ontology. getContainedResource(testNS ,"Person");

List l = person.getSubClass();

 

// get instances of an OWL class

¡­

List employeeList = employee.getInstance();

 

// get domain of OWL property

¡­

List domainList = like.getRDFSDomain();

 

¡­

Table 2 Navigate an OWL ontology

Save OWL ontology to file

In many cases, we need to serialize ontology to file. This can be done by calling OWLXMLSaver.saveToFile(OWLOntology ontology, String fileName, String charset) method.

 

// Save an OWLOntology

try {

OWLXMLSaver.saveToFile(ontology, "./person.owl", "UTF-8");

} catch (IOException e1) {

   e1.printStackTrace();

}

 

Table 3 Save ontology to file

Load OWL ontology from file

There are 2 major steps to load ontology into memory model. The first step is to create an OWLDocument instance which describes information of ontology files and then add to parser. The OWLDocument constructor takes the localURI and the publicURI to locate the document. User can specify whether or not to load the file from local by using the localFile parameter. The second step is to parse ontology by calling the OWLParser.parseOWLDocument (OWLDocument) methods. Table 3 gives a detail example of how to load OWL ontologies.

 

// New an OWL Parser

OWLParser parser = new OWLParserImpl();

 

// New an OWL Document and add to parser

OWLDocument food = new OWLDocumentImpl("./food.owl", null, true);

parser.addOWLDocument(food);

 

OWLDocument wine = new OWLDocumentImpl(null,
                "http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine", false);

parser.addOWLDocument(wine);

 

// Start to parse OWL documents and get OWL ontologies

OWLOntology ontofood = parser.parseOWLDocument(food);

OWLOntology ontowine = parser.parseOWLDocument(wine);

 

Table 4 Loading OWL Ontology

Reuse existing models in other modeling languages

Compared with others tools, the most important differentiation of EODM is its ability of bi-direction transformation between RDF/OWL model and Ecore Model, which gives EODM the interoperability between RDF/OWL model with other EMF supported models, including models defined using XML Schema, Rational Rose, and annotated Java classes. Leveraging EMF and EODM transformer, Semantic Web Application developers can reuse existing models that are represented in other model languages.

 

Table 5 shows a simple example of how to transform an Ecore model into an OWL ontology.

 

// new a Ecore to OWL transformer

ECore2OWLTransformer ecore2owl = new ECore2OWLTransformer();

 

try {

// convert Ecore model to OWL

    ecore2owl. convertEcore2OWL ("./person.ecore","./person.owl");

}

catch (Exception e) {

    e.printStackTrace();

}

Table 5 Transform Ecore Model to OWL Ontology

Inference with EODM Reasoner

The inference ability of OWL is one important distinct feature from other modeling language, such as UML. EODM also provides a reasoner to support inference. Currently EODM reasoner only supports taxonomy subsumption reasoning for OWL reasoning. In other words, EODM reasoner only supports reasoning about relationships between OWL classes and OWL properties.

 

// creating a reasoner

OWLTaxonomyReasoner reasoner = StructuralReasonerFactory.instance()

                .createOWLTaxonmyReasoner();

 

// initialize reasoner

reasoner.initialize(ontology);

...

// get Descendant Classes

List childClass = reasoner.getDescendantClasses(c1);

 

// get Ancestor Property

List plist = reasoner.getAncestorProperties(p1);

 

// test whether two OWL class are subsumed

boolean isSubClass = reasoner.isSubClassOf(c1, c2);

Table 6 Inference with EODM Reasoner

Example Code

The org.eclipse.eodm.examples plugincontains Java code examples for using the EODM API. You can know what the example is about from the name of the Java files.


EODM Basic Workbench Tutorial

From Eclipse menu, select File -> New -> Other, in the popped up dialog, there is an "IODT New Ontology Wizards" category.

The following two sub-sections will introduce you to the basic editing and visual editing respectively.

RDFS/OWL Basic Editing

To create a new RDFS/OWL model and do some basic editing, select File->New->Other, select "OWL Basic Editing" or "RDFS Basic Editing" under the "IODT New Ontology Wizard" category. We select "OWL Basic Editing" as an example to show how basic editing can be used. In the following-up dialog, input the file name of the new OWL model and the folder it should be put. Click "Next>", in the next dialog, select "Ontology" as the model object, as shown below:

 

 

Please select "Ontology" as the model object; it will be used as the container for other model objects. Otherwise, you may not be able to create some model objects.

 

Click "Finish". A basic editor appears in the workspace. Please also open the standard "Properties" view in Eclipse if the view is not shown yet. Click the "Ontology OWLInputStream" node in the tree, the Properties view then list all properties of the ontology resource. Click the value of the "Local Name" and type in any local name you want for the ontology resource. In this example, we give it an "example" local name, as shown below:

Right-click the "Ontology example" node, select "New Child" -> "Contains OWL Class" to create a new OWL Class. Edit the "Local Name" and other properties of the newly created class. In this example, we give it a local name "Man".

 

 

In the Properties view of this "Man" class, click the value of the "RDFS Sub Class Of" property, click the "¡­" button on the right hand, a dialog appears that let you choose the super-classes of the "Man" class. Select "Thing" and click "Add" to add it to "Man"¡¯s super-class. As the following image shows:

 

Hence, the basic editing of RDFS/OWL is based on a tree of model objects and the editing of properties in the standard "Properties" view. Based on the above example of creating a class and adding a sub-class relationship, you can try use the editor to create more model objects and editing other properties. You will soon get familiar with this simple UI.

 

After editing, you can close the editor and save the changes made in the file you created. The ontology will be saved in RDF/XML format. By right-clicking a RDF(S) or OWL model in RDF/XML format file in Eclipse, and selecting "Open With"-> "OWL Model Editor" (or "RDFS Model Editor"), you will be able to open the same simple editor for editing the RDF(S) or OWL ontology, as shown in the following:

If you select to open with "Text Editor", you will be able to view the file directly in the textual RDF/XML format and edit it just like any textual document.