# Common ontology application problems

In this section, we cover some of the common questions or programming tasks that have arisen when writing Jena ontology applications. Brief descriptions of the sample programs are also given.

### Index

1. Combining instance data and schemas (a-boxes and t-boxes)
2. Sample programs

## Combining instance data and schemas (A-box and T-box separation)

In description logic terminology, the t-box contains the axioms defining the classes and relations in an ontology, while the a-box contains the assertions about the individuals in the domain. The RDFS-based ontology languages (RDFS, OWL, DAML+OIL) don't make a distinction between these two categories of information: terminology and instance data may be freely mixed. However, there are some situations in which it is useful to make the separation.

One particular use case for a-box an t-box distinctions is where the assertion data is not directly associated with the terminology declarations. In OWL and DAML+OIL, a document containing instance data can use the imports declaration to indicate the source of the relevant class and property declarations. RDFS does not have an equivalent of imports. There may be other situations in which an OWL document, say, does not directly import the relevant supporting ontologies.

To address this in Jena, we use a capability of the reasoner architecture to separately bind t-box and a-box data sources. The reasoner is associated with the t-box (class and property definitions), then applied to the a-box (instance data).

Assume that the t-box and a-box data sources are specified by URI variables `tBoxURI` and `aBoxURI` respectively. We first define models to hold the data:

    Model tBox = ModelFactory.createDefaultModel();
    tBox.read( tBoxURI );
    Model aBox = ModelFactory.createDefaultModel();
    aBox.read( aBoxURI );

Then, we create a reasoner that will use these declarations:

    Reasoner reasoner = ReasonerRegistry.getOWLReasoner().bindSchema( tBox );

Finally, we create an ontology model specification that includes this reasoner, and use to build an ontology model with the a-box as the base model:

    OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_MEM_RULE_INF );
    spec.setReasoner( reasoner );
    OntModel m = ModelFactory.createOntologyModel( spec, aBox );

## Sample programs

A number sample programs are included in the ontology documentation. These are intended to illustrate approaches to commonly asked questions by users. The intent with these programs is simply to illustrate the approach: they are not intended to be complete solutions to the problem, since the exact requirements for a given solution will depend on the application requirements.

Current example programs are:

- using a persistent (database) model with the ontology API
- printing a listing of the class hierarchy in a model
- generating a textual description of an ontology class

Further example programs may be added in future.