I believe I have found a bug in importing ontologies and annotations. 
Specifically, annotation property values are not included when an ontology is 
imported.

Included in this post are two ontologies, luminary.owl and terrorism.owl. The 
ontology luminary.owl includes the following annotation property declaration:

    <owl:AnnotationProperty rdf:about="#directive">
        <rdfs:comment>Directives indicate how a class or property should be 
handled</rdfs:comment>
    </owl:AnnotationProperty>

This annotation property is used on one datatype property and one class in the 
luminary.owl ontology, and Jena recognizes this. However, the luminary.owl 
ontology is specifically imported (using owl:import), but these annotations 
disappear. Other annotations in the terrorism ontology do appear. To test this, 
I ran the following Java class:

import java.io.FileInputStream;
import java.io.IOException;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.*;

public class DirectiveTest {
    /**
     * TODO: DOCUMENT ME
     *
     * @param args
     */
    public static void main(String[] args) throws IOException {
        if (args.length > 0) {
            OntModel m =
                ModelFactory
                    .createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
            FileInputStream inStream = new FileInputStream(args[0]);
            m.read(inStream, null);
            inStream.close();
            for (StmtIterator stIter =
                m.listStatements(null, null, (RDFNode) null); 
stIter.hasNext();) {
                Statement stmt = stIter.next();
                if (stmt.toString().contains("directive")) {
                    System.out.println(stmt);
                }
            }
        }
    }
}

On the Luminary ontology, it outputs the following, showing that the directive 
annotation is recognized on the DatatypeProperty and Class:

[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#type, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#Property]
[http://luminary.unx.sas.com/luminary#Message, 
http://luminary.unx.sas.com/luminary#directive, "Test"]
[http://luminary.unx.sas.com/luminary#hasDescription, 
http://luminary.unx.sas.com/luminary#directive, "TextField"]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/2000/01/rdf-schema#comment, "Directives indicate how a class 
or property should be handled"]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#type, 
http://www.w3.org/2002/07/owl#AnnotationProperty]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/2000/01/rdf-schema#subPropertyOf, 
http://luminary.unx.sas.com/luminary#directive]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#type, 
http://www.w3.org/2000/01/rdf-schema#Resource]

However, when I run the same code on the terrorism ontology, the annotations in 
terrorism.owl do appear, but those in luminary.owl do not. I would expect that 
since the ontology is specifically imported, all directives would appear. 
Instead, I get the following results:

[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#type, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#Property]
[http://luminary.unx.sas.com/bls#Event, 
http://luminary.unx.sas.com/luminary#directive, "Abstract"]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/2000/01/rdf-schema#comment, "Directives indicate how a class 
or property should be handled"]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#type, 
http://www.w3.org/2002/07/owl#AnnotationProperty]
[http://luminary.unx.sas.com/luminary#Event, 
http://luminary.unx.sas.com/luminary#directive, "Abstract"]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/2000/01/rdf-schema#subPropertyOf, 
http://luminary.unx.sas.com/luminary#directive]
[http://luminary.unx.sas.com/luminary#directive, 
http://www.w3.org/1999/02/22-rdf-syntax-ns#type, 
http://www.w3.org/2000/01/rdf-schema#Resource]

I would understand an annotation not being included with just a namespace 
reference. But with a specific owl:import, I'd expect that the annotations 
would also be included.

Edward Swing
Applied Research Technologist
Vision Systems + Technology, Inc., a SAS Company
6021 University Boulevard * Suite 360 * Ellicott City * Maryland * 21043
Tel: 410.418.5555 Ext: 919 * Fax: 410.418.8580
Email: [email protected]<mailto:[email protected]>
Web: http://www.vsticorp.com<http://www.vsticorp.com/>

Reply via email to