简体   繁体   English

耶拿显示了本体类的错误名称空间

[英]Jena showing wrong namespace for ontology classes

I have a local ontology with several classes, such as User : 我有几个类的本地本体,例如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>

If I try to print all the classes like this: 如果我尝试打印所有这样的类:

/* Lists all classes */
ExtendedIterator<OntClass> classIterator = model.listClasses(); 
while (classIterator.hasNext()) { 
    OntClass ontClass = classIterator.next(); 
    System.out.println(ontClass.toString()); 
}

I get them with a local path: 我用本地路径获取它们:

file:///home/myusername/#User

Instead of 代替

http://www.somedomain.com/data/#User

This is very annoying because my namespace in Jena is therefore file:///home/myusername/# and I do not believe this is correct. 这非常令人讨厌,因为我在耶拿(Jena)中的命名空间是file:///home/myusername/# ,我不认为这是正确的。 What am I doing wrong? 我究竟做错了什么?

<rdfs:Class rdf:ID="User">

means resolve "User" against the base URI, which is file:///home/myusername/. 表示根据基本URI(文件:/// home / myusername /)解析“用户”。 This is correct. 这是对的。

Either set the base URI to what you require in the model.read operation or you can give the URI: an XML entity useful: define the entity and in rdf:ID=".." and xmlns:domain=".." 可以将基本URI设置为您在model.read操作中所需的值,或者可以给URI:一个有用的XML实体:定义该实体,并在rdf:ID =“ ..”和xmlns:domain =“ ..”中定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM