I created a simple ontology with two classes (A and B) that are disjoint
with eachother.
Then I created RDF data assigning the same resource being rdf:type class A
and in another statement made the same resource rdf:type Class B.
I expected the owl reasoner to give a validation error but it didn't give me
any error when running the validation on it.
I don't think this is a bug, but rather my understanding of what the
reasoned is actually validating, and perhaps the way I defined the ontology
and the data.
See code below. Why is the validator not throwing an error even though the
data is inconsistent with the ontology?
Ontology:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:questionSample1="http://www.semanticweb.org/ontologies/2012/5/question
Sample1.owl#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/2012/5/questionSample1.owl#
ClassB">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/2012/5/questionSample1.owl#
ClassA">
<!--- note the disjointWith here -->
<owl:disjointWith
rdf:resource="http://www.semanticweb.org/ontologies/2012/5/questionSample1.o
wl#ClassB"/>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/2012/5/questionSample1.owl"
>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
</rdf:Description>
<rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/2012/5/questionSample1.owl#
prop1">
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
<rdfs:domain
rdf:resource="http://www.semanticweb.org/ontologies/2012/5/questionSample1.o
wl#ClassA"/>
<rdf:type
rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
</rdf:Description>
</rdf:RDF>
Code:
public static void main(String[] args) {
OntModel ontm =
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF);
ontm.read("file:///E:/projects/JenaFirst/src/tutorial/resources/data/questio
nSample1.owl","RDF/XML");
ontm.write(System.out,"RDF/XML");
Model m = ModelFactory.createDefaultModel();
Resource rs =
ResourceFactory.createResource("http://exanple.org/A-product");
m.add(rs, RDF.type,
"http://www.semanticweb.org/ontologies/2012/5/questionSample1.owl#ClassA");
m.add(rs, RDF.type,
"http://www.semanticweb.org/ontologies/2012/5/questionSample1.owl#ClassB");
ontm.add(m);
ValidityReport vr = ontm.validate();
for (Iterator<ValidityReport.Report> rep = vr.getReports();
rep.hasNext();) {
ValidityReport.Report report = rep.next();
System.out.println(report.toString());
}
}