0
public class List_subPropertyOf {
//static final String inputFileName = "data/dbpedia_3.9.owl";
//static final String inputFileName = "data/wnfull.rdfs";
static final String inputFileName = "data/lov.rdf";
public static void main(String args[]) {
try {
//create the reasoning model using the base
OntModel inf = ModelFactory.createOntologyModel();
// use the FileManager to find the input file
InputStream in = FileManager.get().open(inputFileName);
File logFile = new File("List_subPropertyOf.txt");
PrintStream logPrintStream = new PrintStream(logFile);
System.setOut(logPrintStream);
if (in == null) {
throw new IllegalArgumentException("File: " + inputFileName + " not found");
}
inf.read(in, "", "RDF/XML");
ExtendedIterator properties = inf.listOntProperties();
while (properties.hasNext()) {
OntProperty essaProperty = (OntProperty) properties.next();
System.out.println("Property: " + essaProperty.getLocalName());
for (Iterator i = essaProperty.listSubProperties(); i.hasNext();) {
OntProperty c = (OntProperty) i.next();
System.out.print(" " + c.getLocalName() + "\n");
} // end for
}
} catch (Exception e) {
System.out.println(e);
}
}
例外: 請看照片。 我該怎麼辦?我沒有足夠的聲望發佈圖片。我不能發佈一個例外超過2個鏈接,但我的異常有...看來我無法將.rdf文件讀入OntModel(.rdfs和.owl是好的。)
16時55分37秒WARN OntDocumentManager ::試圖從http://www.ontotext.com/proton/protontop讀取出錯。 msg是'org.xml.sax.SAXParseException:在prolog中不允許使用內容'。 com.hp.hpl.jena.shared.JenaException:org.xml.sax.SAXParseException:在prolog中不允許使用內容。