【发布时间】:2011-06-28 19:59:46
【问题描述】:
我使用 RDFS 创建了一个本体,使用相对 URIrefs 来保存击键。现在,我想用 Jena 加载本体并用它来构造我的数据。但是,当我使用m.read("file:flow-schema.rdf"); 读取文件并使用m.write(System.out, "RDF/XML-ABBREV", "http://flowschema/#"); 显示它时,相对URIrefs 以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/#");
【问题讨论】: