How Owl Imports Work

From Protege Wiki
Revision as of 10:05, April 28, 2008 by Tredmond (talk | contribs) (Ontology Found Has The Wrong Name)

Jump to: navigation, search

OWL Imports

First it must be understood that the semantics of imports in OWL is a subject of some controversy. In the OWL 1.1 specification there is effort in progress to clear up some of this confusion. Until this is settled we will use the definition of the semantics of imports given in the semantics document of the specs:

Aside from this local meaning, an owl:imports annotation also imports the contents of another OWL ontology into the current ontology. The imported ontology is the one, if any, that has as name the argument of the imports construct. (This treatment of imports is divorced from Web issues. The intended use of names for OWL ontologies is to make the name be the location of the ontology on the Web, but this is outside of this formal treatment.)

In this note we will describe what this innocent little paragraph is saying and what it means to Protege.

Names of Ontologies

All owl ontologies have a name. The document describing this naming process can be found at this link. Unfortunately the way that this name is calculated (at least for the RDF/XML OWL syntax) is not well specified. Even so - in most cases it can be calculated in an unambiguous way. In most RDF/XML ontologies there is a single RDF resource that is declared to be of type owl:Ontology. So for instance in the pizza owl ontology, the declaration in question is the following:

 <owl:Ontology rdf:about="">
   <protege:defaultLanguage rdf:datatype=""
   <owl:versionInfo rdf:datatype=""
   >version 1.3</owl:versionInfo>
   <rdfs:comment xml:lang="en">An example ontology that contains all constructs required for the various versions of the Pizza Tutorial run by Manchester University (see</rdfs:comment>
   <owl:imports rdf:resource=""/>

The first line of this declaration defines an RDF resource of type owl:Ontology. The name of this resource is given by the rdf:about statement. In this case the rdf:about string is empty which means that the xml base is used. The xml:base declaration can be found near the top of the pizza ontology in the namespace declarations:


No other declarations of an owl:Ontology resource occur in the pizza ontology so the name of this resource (e.g. is the name of the pizza ontology. It is relevant to this discussion that the name of the pizza ontology is working URL and clicking on the link pulls up the pizza ontology. In summary:

  • the pizza ontology contains exactly one owl:Ontology declaration,
  • this declaration is named by rdf:about="",
  • the xm:base is declared and
  • the xml:base is a working URL that points to the pizza ontology.

This situation is the simplest case and in this case things tend to work very smoothly.

However none of the assumptions above are guaranteed to hold. Sometimes there are no owl:Ontology declarations in the owl ontology. In this case the document base is used as the name of the ontology. The document base is given by xml:base statement or the the physical location that was used to retrieve the ontology if no xml:base declaration is present. If this is still ambiguous, I am not sure what happens.

In addition sometimes the rdf:about statement does not use the empty string. This allows one to give the ontology a name other than the xml:base. Finally the name of the ontology may only be a URI and may not resolve to the right ontology as a URL. Each of these cases adds some difficulty to ontology developers and to some degree motivate the writing of this document.

There is another case that has been troublesome in the past. Occasionally in some cases there are more than one owl:Ontology declaration. In this case tools occasionally get confused and give different results. Protege works by taking the first declaration of an owl:Ontology individual to be the name of the ontology. This would be fine except that the notion of first declaration in RDF/XML is not well defined.

Import By Name

If we look at the owl:Ontology header of the pizza ontology, we see that the declared owl:Ontology resource is related to another resource by the owl:imports property:

 <owl:Ontology rdf:about="">
   <protege:defaultLanguage rdf:datatype=""
   <owl:versionInfo rdf:datatype=""
   >version 1.3</owl:versionInfo>
   <rdfs:comment xml:lang="en">An example ontology that contains all constructs required for the various versions of the Pizza Tutorial run by Manchester University (see</rdfs:comment>
   <owl:imports rdf:resource=""/>

As triples the owl:imports statement would look like this:

<> owl:imports <>.

This statement tells tools such as Protege or reasoners that the pizza ontology should import an ontology whose name is

So now the problem is "how do we find an ontology with this name?". The easy answer would be to simply use the name of the imported ontology as a URL and fetch the imported ontology in this way. Most of the time this works (e.g. this example) but in general the retrieval is not that simple.

Suppose that you are on a train commuting home from work with no internet connection and you decide to edit the pizza ontology. If Protege uses the URL to try to retrieve the ontology it will fail. In this case, this will not be that inconvenient. The user can still edit. But with more complex ontologies with more critical imports (e.g. the birnlex ontology) not finding the imports may make working on the ontology impossible.

In this case, both Protege 3 and Protege 4 (and most other owl ontology tools) have a mechanism by which a user can tell the tool where to search for an ontology with the right name. In Protege 3 the spaces of ontologies to search are called ontology repositories. In Protege 4 they are called ontology libraries. A typical ontology repository or library will consist of all the ontologies in a given directory on the disk. When Protege is trying to resolve an import, it will first search in all the defined ontology repositories for an ontology whose name matches the desired imported name. If it doesn't find any matches, then it tries the ontology name as a URL. If this fails then the import will fail. This is not generally a fatal error, it just means that Protege does not have access to the assertions contained in that import.

The repository mechanism for Protege 3 is described at link. The Protege 4 ontology library documentation will be coming soon.

What Can Go Wrong

There are two main things that can go wrong. First Protege may fail to find the imported ontology and second Protege may follow the above algorithm but end up retrieving an ontology with the wrong name.

Ontology Not Found

The ontology

has an import statement that points to an ontology that does not exist. In this case both Protege 3 and Protege 4 will generate a dialog with the user to find the location of the imported file. The user has the choice of either ignoring the import or pointing Protege to a location where the imported ontology can be found.

In Protege 3 the dialog looks like this: HowOwlImportsWorkProtege3NotFound.png

In Protege 4 the dialog looks like this: HowOwlImportsWorkProtege4NotFound.png

Ontology Found Has The Wrong Name

The ontology at the location

has an import statement that imports an ontology with the wrong name. More specifically the ontology header is as follows:

 <owl:Ontology rdf:about="">
   <owl:imports rdf:resource=""/>

However if you follow the link it turns out that the name of the ontology in this location is

So in this case, if Protege follows the specification of imports described above then it would not import any statements from the ontology found at the location The ontology found at that location is not the ontology requested by the import. So the import is not found. Strictly speaking, this is the correct behavior of the Protege tool.

However this behavior is almost never what the user wants. So in both Protege 3 and Protege 4 we adopted a compromise position. We import the assertions from the ontology

that we found at the location and we leave a visual cue in the imports tree for the ontology that the import is broken.

In Protege 4 the visual cue is the little green triangle to the right in the diagram below: HowOwlmportsWorkProtege4Broken.png

A nice feature of Protege 4 is that clicking on the green triangle will bring up a dialog that asks if you want to fix the import: HowOwlmportsWorkProtege4Fix.png