[英]Jena showing wrong namespace for ontology classes
我有幾個類的本地本體,例如User
:
<rdf:RDF
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:domain="http://www.somedomain.com/data/#">
<rdfs:Class rdf:ID="User">
<rdfs:subClassOf rdf:resource="http://xmlns.com/foaf/0.1/Agent" />
<rdfs:comment>
The class of users.
</rdfs:comment>
</rdfs:Class>
</rdf:RDF>
如果我嘗試打印所有這樣的類:
/* Lists all classes */
ExtendedIterator<OntClass> classIterator = model.listClasses();
while (classIterator.hasNext()) {
OntClass ontClass = classIterator.next();
System.out.println(ontClass.toString());
}
我用本地路徑獲取它們:
file:///home/myusername/#User
代替
http://www.somedomain.com/data/#User
這非常令人討厭,因為我在耶拿(Jena)中的命名空間是file:///home/myusername/#
,我不認為這是正確的。 我究竟做錯了什么?
<rdfs:Class rdf:ID="User">
表示根據基本URI(文件:/// home / myusername /)解析“用戶”。 這是對的。
可以將基本URI設置為您在model.read操作中所需的值,或者可以給URI:一個有用的XML實體:定義該實體,並在rdf:ID =“ ..”和xmlns:domain =“ ..”中定義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.