当我运行“getEquivalentClass()”并且我的等价类是远程的(例如:http://dbpedia.org/data3/Film.rdf )时引发错误:
无法将节点http://dbpedia.org/data3/Film.rdf转换为 OntClass:它没有 rdf:type owl:Class 或等效项
我的代码是:
OntModel m = ModelFactory.createOntologyModel();
m.read("http://localhost/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());
}
电影本体(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>
有可能吗?我浪费了很多时间来寻找这个解决方案。
谢谢你帮助我!