On 30/03/13 23:26, Leandro Andrade wrote:
Hi,
Sorry for possible duplicate message.
I have a question, that I didn't find solution in web.
When I run "getEquivalentClass()" and my equivalentClass is remote (EX:
http://dbpedia.org/data3/Film.rdf) raise error:
*Cannot convert node http://dbpedia.org/data3/Film.rdf to OntClass: it does
not have rdf:type owl:Class or equivalent*
My code is:
OntModel m = ModelFactory.createOntologyModel();
m.read("http://127.0.0.1/ontology/my_ontology.owl#Film");
Resource r =
m.getResource(outputs.get(i).getParamType().getURI().toString());
OntClass filmClass = (OntClass) r.as( OntClass.class );
for (Iterator j = filmClass.listEquivalentClasses(); j.hasNext(); ) {
System.out.println(j.next());
}
Film Ontology (http://127.0.0.1/ontology/my_ontology.owl#Film):
<owl:Class rdf:about="#Film">
<rdfs:subClassOf rdf:resource="#Media"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:minCardinality rdf:datatype="
http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:minCardinality>
<owl:onProperty rdf:resource="#Title"/>
</owl:Restriction>
</rdfs:subClassOf>
*<owl:equivalentClass rdf:resource="http://dbpedia.org/data3/Film.rdf"/>*
</owl:Class>
It's is possible? I lost many hours finding this solution.
It's not to do with whether the resource is remote but whether the local
model knows that the resource really is a class.
The easiest solution is to just set:
m.setStrictMode(false);
An alternative is to enable inference so the inference can deduce from
the fact that it is the object of an owl:equivalentClass assertion that
http://dbpedia.org/data3/Film.rdf must be a class. But inference is
overkill here.
BTW that's the wrong URI, the dbpedia resource URI for film is actually:
http://dbpedia.org/ontology/Film
Dave