入力クラスのサブクラスをロードするメソッドを作成しようとしています。このコードは、OWL API 3.1.x (Pizza.owl) で作成された RDF ファイルでは問題なく動作していましたが、OWL API 3.4.x バージョンで生成されたファイルでは動作しません。
以下は私が書いたコードです:
public ArrayList<String> getSubClassOf(String parentClass)
{
String seq = "";
tempList.clear();
tempClass = factory.getOWLClass(":" + parentClass, pm);
s = reasoner.getSubClasses(tempClass, false);
i = s.iterator();
while(i.hasNext()){
seq = i.next().toString();
if(!seq.contains("Nothing"))
tempList.add(seq.substring(seq.indexOf("#")+1,seq.indexOf(">")));
}
return tempList;
}
これは、OWL API 3.4.2 によって生成されたフクロウ ファイルです。
<!DOCTYPE Ontology [
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY xml "http://www.w3.org/XML/1998/namespace" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://localhost/CA/SmartHome/SmartHome_1113"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
ontologyIRI="http://localhost/CA/SmartHome/SmartHome_1113">
<Prefix name="" IRI="http://localhost/CA/SmartHome/SmartHome_1113.owl#"/>
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<Declaration>
<Class IRI="#Adult"/>
</Declaration>
<Declaration>
<Class IRI="#Person"/>
</Declaration>
<SubClassOf>
<Class IRI="#Adult"/>
<Class IRI="#Person"/>
</SubClassOf>
</Ontology>
2つのクラスからなる非常にシンプルなオントロジーで、AdultはPersonのサブクラスです