Apparently, properties are not imported when an ontology is imported - not even 
the subclass relationship. To test this, I have created two simple ontologies. 
First, the base (imported) ontology:

<!DOCTYPE rdf:RDF [
    <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#"; >
    <!ENTITY owl  "http://www.w3.org/2002/07/owl#"; >
    <!ENTITY rdf  "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; >
]>


<rdf:RDF xmlns="http://luminary.unx.sas.com/test#";
       xml:base="http://luminary.unx.sas.com/test#";
       xmlns:owl="http://www.w3.org/2002/07/owl#"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
       xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema#";>

       <owl:Ontology rdf:about="TestBase">
              <rdfs:comment>Test Base Ontology</rdfs:comment>
              <rdfs:label>Test Base Ontology</rdfs:label>
       </owl:Ontology>

       <owl:Class rdf:ID="Person" />
       <owl:Class rdf:ID="Teacher">
           <rdfs:subClassOf rdf:resource="#Person" />
       </owl:Class>
</rdf:RDF>

Next, the importing ontology:

<!DOCTYPE rdf:RDF [
    <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#"; >
    <!ENTITY owl  "http://www.w3.org/2002/07/owl#"; >
    <!ENTITY rdf  "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; >
    <!ENTITY tst  "http://luminary.unx.sas.com/test#"; >
]>


<rdf:RDF xmlns="http://luminary.unx.sas.com/import#";
       xml:base="http://luminary.unx.sas.com/import#";
       xmlns:owl="http://www.w3.org/2002/07/owl#"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
       xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema#";
       xmlns:tst="http://luminary.unx.sas.com/test#";>

       <owl:Ontology rdf:about="TestImport">
              <rdfs:comment>Test Import Ontology</rdfs:comment>
              <rdfs:label>Test Import Ontology</rdfs:label>
              <owl:imports 
rdf:resource="http://luminary.unx.sas.com/luminary/testbase.owl"/>
       </owl:Ontology>

       <owl:Class rdf:ID="Administrator">
           <rdfs:subClassOf rdf:resource="&tst;Person" />
       </owl:Class>
</rdf:RDF>

Finally, here is the Java class I wrote to test this:

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Iterator;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.RDFS;

public class SubclassTest {

    public static void main(String[] args) throws IOException {
        OntModel model =
            ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
        FileInputStream inStream =
            new FileInputStream("resources/testimport.owl");
        model.read(inStream, null);
        inStream.close();
        for (Iterator<OntClass> clsIter = model.listClasses(); clsIter
            .hasNext();) {
            OntClass cls = clsIter.next();
            System.out.println("CLS: " + cls.getURI());
            for (StmtIterator stIter =
                model.getBaseModel().listStatements(cls, RDFS.subClassOf,
                    (RDFNode) null); stIter.hasNext();) {
                Statement stmt = stIter.next();
                RDFNode obj = stmt.getObject();
                if (obj.isURIResource()) {
                    OntClass par = model.getOntClass(obj.toString());
                    System.out.println("  Parent: " + par.getURI());
                }
            }
        }
    }
}

The output from the class shows the following (I've trimmed the 
www.w3.org<http://www.w3.org> classes from this for brevity):

CLS: http://luminary.unx.sas.com/import#Administrator
  Parent: http://luminary.unx.sas.com/test#Person
CLS: http://luminary.unx.sas.com/test#Teacher
CLS: http://luminary.unx.sas.com/test#Person

Clearly, the Teacher is a subclass of Person, as it is defined in the base 
ontology. However, this relationship does not appear. When an ontology is 
imported, it is supposed to import all definitions and statements. However, 
this is clearly not the case.

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