我用RDFS創建了一個本體,使用相對的URIrefs來保存擊鍵。現在,我想用Jena加載本體並用它來構建我的數據。但是,當我使用m.read("file:flow-schema.rdf");
讀取文件並將其與m.write(System.out, "RDF/XML-ABBREV", "http://flowschema/#");
一起顯示時,相對URIref的前綴爲file:flow-schema.rdf
,而不是http://flowschema/#
。如何更改從文件加載的本體的默認前綴?從文件加載本體時,如何覆蓋默認前綴?
這是我的本體文件:
<?xml version="1.0" ?>
<!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:base="http://flowschema/#">
<rdfs:Class rdf:ID="Flow" />
<rdf:Property rdf:ID="srcIP">
<rdfs:domain rdf:resource="#Flow" />
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal" />
</rdf:Property>
<rdf:Property rdf:ID="dstIP">
<rdfs:domain rdf:resource="#Flow" />
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal" />
</rdf:Property>
</rdf:RDF>
這裏的Java代碼,從文件中讀取本體:
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
m.read("file:flow-schema.rdf");
m.write(System.out, "RDF/XML-ABBREV", "http://flowschema/#");