我有以下RDF:
<?xml version="1.0" encoding="UTF-8"?>
<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:ppl="http://www.blah.com/people#">
<rdfs:Class rdf:ID="Person">
<ppl:Name/>
<ppl:LastName/>
</rdfs:Class>
<rdfs:Class rdf:ID="John">
<rdfs:subClassOf rdf:resource="#Person"/>
<ppl:name>John</ppl:name>
<ppl:LastName>Smith</ppl:LastName>
</rdfs:Class>
</rdf:RDF>这看起来很好,但我想避免做一个subClassOf John的可能性。例如,这应该不起作用:
<?xml version="1.0" encoding="UTF-8"?>
<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:ppl="http://www.blah.com/people2#">
<rdfs:Class rdf:ID="Person">
<ppl:Name/>
<ppl:LastName/>
</rdfs:Class>
<rdfs:Class rdf:ID="John">
<rdfs:subClassOf rdf:resource="#Person"/>
<ppl:name>John</ppl:name>
<ppl:LastName>Smith</ppl:LastName>
</rdfs:Class>
<rdfs:Class rdf:ID="Peter">
<rdfs:subClassOf rdf:resource="#John"/>
<ppl:name>Peter</ppl:name>
<ppl:LastName>Smith</ppl:LastName>
</rdfs:Class>
</rdf:RDF>我如何添加该限制?
编辑:
在cygri's answer之后,我尝试了一种不同的方法:
<rdf:Description ID="John">
<rdf:type rdf:resource="#Person"/>
<ppl:name>John</ppl:name>
<ppl:LastName>Smith</ppl:LastName>
</rdf:Description>
<rdf:Description ID="Peter">
<rdf:type rdf:resource="#John"/>
<ppl:name>Peter</ppl:name>
<ppl:LastName>Smith</ppl:LastName>
</rdf:Description>但这仍然有效:(
发布于 2010-07-02 05:31:50
不知道你想做什么。你的模特儿在我看来很奇怪,为什么约翰是个班级?约翰应该是个人类型的人。(您不能有个体的子类,因此将John更改为个体也回答了您关于防止子类化的问题。)
更新: RDF本身并不妨碍您说无稽之谈。因此即使数据是无意义的,您仍然可以解析、序列化和查询数据。但是您可以使用OWL一致性检查器来验证您的本体。在这种情况下,您必须检查本体是否在OWL DL中。(OWL DL是OWL的变体,它引入了个人不能具有子类等限制。在OWL Full中,这是允许的,除非您添加了Class类与Person类不相交的约束。
发布于 2010-07-09 01:52:30
你还把约翰当做一个班级。你想要这样的东西:
<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:ppl="http://www.blah.com/people#">
<rdfs:Class rdf:ID="Person" />
<rdf:Description rdf:ID="John">
<rdf:type rdf:resource="#Person"/>
<ppl:name>John</ppl:name>
<ppl:LastName>Smith</ppl:LastName>
</rdf:Description>
</rdf:RDF>rdfs:subClassOf和rdf:type是不同种类的关系。
subClassOf用于说明,比如说,所有的人都是哺乳动物,所有的哺乳动物都是动物。
rdf:type用于说明,比如说,John是一个人( John是一只哺乳动物,就这一点而言,John是一只动物)。
无论如何,semanticoverflow.com也是一个询问RDF相关问题的好地方。
https://stackoverflow.com/questions/3159229
复制相似问题