Search code examples
javaowlsemanticsowl-apiturtle-rdf

OWLOntology readOntology creates AnnotationProperty


I have to read an ontology, using OWLAPI; I use this JAVA code:

public class OwlApi {

public static void main(String[] args) throws OWLOntologyCreationException, FileNotFoundException {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        File file = new File("myfile");
        InputStream targetStream = new FileInputStream(file);
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(targetStream);      
}
}

My file is a simple turtle file, like this:

@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix : <platform:/resource/test/OWL/prova#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<platform:/resource/test/OWL/prova> a owl:Ontology .

:proprietao a owl:ObjectProperty ;
rdfs:domain :classeuno ;
rdfs:range <http://dbpedia.org/ontology/PopulatedPlace> .

:proprietad a owl:DatatypeProperty ;
rdfs:domain <http://dbpedia.org/ontology/PopulatedPlace> ;
rdfs:range xsd:string .

:classeuno a owl:Class .

The outuput of loading the file is this one:

Ontology(OntologyID(OntologyIRI(<platform:/resource/test/OWL/prova>) VersionIRI(<null>))) [Axioms: 7 Logical Axioms: 3] First 20 axioms: {DataPropertyRange(<platform:/resource/test/OWL/prova#proprietad> xsd:string) DataPropertyRange(<platform:/resource/test/OWL/prova#proprietao> <http://dbpedia.org/ontology/PopulatedPlace>) Declaration(ObjectProperty(<platform:/resource/test/OWL/prova#proprietao>)) Declaration(DataProperty(<platform:/resource/test/OWL/prova#proprietad>)) Declaration(Class(<platform:/resource/test/OWL/prova#classeuno>)) AnnotationPropertyDomain(<platform:/resource/test/OWL/prova#proprietad> <http://dbpedia.org/ontology/PopulatedPlace>) ObjectPropertyDomain(<platform:/resource/test/OWL/prova#proprietao> <platform:/resource/test/OWL/prova#classeuno>) }

I don't understand why is appearing a AnnotationPropertyDomain about the DataProperty.

Am I doing something wrong? Thanks so much.


Solution

  • This happens because http://dbpedia.org/ontology/PopulatedPlace is not declared as owl:Class and the parser is very strict. In OWL you have to type all entities explicitly.