本站首页    管理页面    写新日志    退出


«October 2025»
1234
567891011
12131415161718
19202122232425
262728293031


公告
暂无公告...

我的分类(专题)

日志更新

最新评论

留言板

链接


Blog信息
blog名称:
日志总数:8
评论数量:19
留言数量:0
访问次数:70255
建立时间:2006年8月1日




[Semantic Web]一个关于RDF的简单问题(关于rdf:ID,rdf:about,rdf:resource的用法)
文章收藏

爱睡觉的猫 发表于 2006/8/3 16:06:31

用Protege建立一个本体,关于Pizza的,有三个类,包括Pizza, PiazzaBase和PizzaTopping,他们互相Disjointwith,我原以为这三个类既然是在层次上对等的,那代码也应该差不多。但是当我查看源代码时发现自动生成的代码中,这三个类是不一样的,主要是有些用的是rdf:ID,有些用的是rdf:about,还有用rdf:resource的,如下: <?xml version="1.0"?> <rdf:RDF     xmlns:owl="http://www.w3.org/2002/07/owl#"     xmlns="http://www.owl-ontologies.com/unnamed.owl#"     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xml:base="http://www.owl-ontologies.com/unnamed.owl">   <owl:Ontology rdf:about=""/>   <owl:Class rdf:ID="PizzaBase">     <owl:disjointWith>       <owl:Class rdf:ID="Pizza"/>     </owl:disjointWith>     <owl:disjointWith>       <owl:Class rdf:ID="PizzaTopping"/>     </owl:disjointWith>   </owl:Class>   <owl:Class rdf:about="#Pizza">     <owl:disjointWith rdf:resource="#PizzaBase"/>     <owl:disjointWith>       <owl:Class rdf:about="#PizzaTopping"/>     </owl:disjointWith>   </owl:Class>   <owl:Class rdf:about="#PizzaTopping">     <owl:disjointWith rdf:resource="#PizzaBase"/>     <owl:disjointWith rdf:resource="#Pizza"/>   </owl:Class> </rdf:RDF> 同样的结构,为什么有些要用rdf:resource有些又用rdf:about,还有些用rdf:ID?这几个有什么区别呢? 一些网友的观点: 1. 1)rdf:ID和rdf:about的区别: rdf:about的值是一个完整URIref,注意也可以是相对URI,(相对于xml:base);rdf:ID是对rdf:about的值的缩写,其值是一个“ XML Name”,所以,不能是数字开头,不能有“/”符号等。 例如:rdf:ID="PizzaBase" 等价于rdf:about="(xml:base)+‘#’+‘PizzaBase’ "这个xml:base的值可以在XML文件头声明,如你例子中的,xml:base="http://www.owl-ontologies.com/unnamed.owl", 如果没有声明,则其值是RDF文件所放在的位置uri。 2)rdf:resource 和rdf:about <owl:disjointWith rdf:resource="#PizzaBase"/> 是 <owl:disjointWith >   <rdf:Description rdf:about="#PizzaBase" /></owl:disjointWith >的缩写。这里必须没有对资源="#PizzaBase" 做进一步的说明。所以,rdf:resource只能出现在表示属性的节点中,如这里的owl:disjointWith节点。 而  <owl:disjointWith>             <owl:Class rdf:about="#PizzaTopping"/>    </owl:disjointWith>是等价于:<owl:disjointWith >   <rdf:Description rdf:about="#PizzaTopping" >         <rdf:type rdf:resource="&rdfs;Class" />   </rdf:Description></owl:disjointWith > 这里不能用rdf:resource了,因为声明了#PizzaTopping是一个类。 所以,我们可以看出:说明了:  <owl:Class rdf:ID="PizzaBase">以后,后面的都是用: <owl:disjointWith rdf:resource="#PizzaBase"/>了。 2.其实我们可以把rdf:ID看作和rdf:about一样的东西,rdf:ID只是一个缩写而已。所以  <owl:Class rdf:ID="PizzaBase">     <owl:disjointWith>       <owl:Class rdf:ID="Pizza"/>     </owl:disjointWith>     <owl:disjointWith>       <owl:Class rdf:ID="PizzaTopping"/>     </owl:disjointWith>   </owl:Class>中,把所有的rdf:ID="xxx"替换成rdf:about="#xxx"也是可以的,这是我的第一个理解。 第二,为什么这里不能用rdf:resource呢,是因为到目前为止,Pizza类和PizzaTopping类还没有被定义,需要在这里申明它是一个类。如果Pizza类在之前就已经定义了,那么这里也可以用rdf:resource来简写。 3.再补充一个rdf:ID和rdf:about的区别: rdf:ID是用来定义一个资源,或者说引入一个新的资源名称;rdf:about除了也可用来定义资源外,还可用来扩展对这个资源的定义(这可以出现在其他本体文件中)。 如果Pizza是用rdf:ID定义的,那么要增加对Pizza的描述,就必须用rdf:about。因为同一个RDF文档中,不能出现两个rdf:ID="Pizza",否则RDF Parser就会报错。参见: {{//RDF Primer. Section 3.2 的第4段中间  However, using rdf:ID provides an additional check when assigning a set of distinct names, since a given value of the rdf:ID attribute can only appear once relative to the same base URI (the catalog document, in this example). 4.Have you looked at the RDF Primer (and specifically, Example 4 inSection 3.1 and its explanation, which is where this is discussed)?Basically, rdf:about is for expressing the *subject* of an RDF statementin RDF/XML.  rdf:resource is for expressing the *object* of an RDFstatement in RDF/XML, when the object is another resource rather than aliteral value.  Does that help?  If you have some particular example inmind that you are trying to express, could you provide it? --Frank 按照Frank的说法,rdf:about用来表示statement的主体,rdf:resource在statement的客体是一个资源而不是文字值时用来表示客体 5.在RDF primer的第三章有解释:http://www.w3.org/TR/rdf-primer/其中的对rdf:ID的解释:An important difference from previous examples is that, in line 5, the rdf:Description element has an rdf:ID attribute instead of an rdf:about attribute. Using rdf:ID specifies a fragment identifier, given by the value of the rdf:ID attribute (item10245 in this case, which might be the catalog number assigned by example.com), as an abbreviation of the complete URIref of the resource being described. The fragment identifier item10245 will be interpreted relative to a base URI, in this case, the URI of the containing catalog document. The full URIref for the tent is formed by taking the base URI (of the catalog), and appending the character "#" (to indicate that what follows is a fragment identifier) and then item10245 to it, giving the absolute URIref http://www.example.com/2002/04/products#item10245. The rdf:ID attribute is somewhat similar to the ID attribute in XML and HTML, in that it defines a name which must be unique relative to the current base URI (in this example, that of the catalog). In this case, the rdf:ID attribute appears to be assigning a name (item10245) to this particular kind of tent. Any other RDF/XML within this catalog could refer to the tent by using either the absolute URIref http://www.example.com/2002/04/products#item10245, or the relative URIref #item10245. The relative URIref would be understood as being a URIref defined relative to the base URIref of the catalog. Using a similar abbreviation, the URIref of the tent could also be given by specifying rdf:about="#item10245" in the catalog entry (i.e., by specifying the relative URIref directly) instead of rdf:ID="item10245" . As an abbreviation mechanism, the two forms are essentially synonyms: the full URIref formed by RDF/XML is the same in either case: http://www.example.com/2002/04/products#item10245. However, using rdf:ID provides an additional check when assigning a set of distinct names, since a given value of the rdf:ID attribute can only appear once relative to the same base URI (the catalog document, in this example). Using either form, example.com would be giving the URIref for the tent in a two-stage process, first assigning the URIref for the whole catalog, and then using a relative URIref in the description of the tent in the catalog to indicate the URIref that has been assigned to this particular kind of tent. Moreover, this use of a relative URIref can be thought of either as being an abbreviation for a full URIref that has been assigned to the tent independently of the RDF, or as being the assignment of the URIref to the tent within the catalog.


阅读全文(2637) | 回复(1) | 编辑 | 精华
 


回复:一个关于RDF的简单问题(关于rdf:ID,rdf:about,rdf:resource的用法)
文章收藏

heima(游客)发表评论于2006/12/26 15:54:54

很好 谢谢


个人主页 | 引用回复 | 主人回复 | 返回 | 编辑 | 删除
 


» 1 »

发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.031 second(s), page refreshed 144791088 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号