RDF Basics
RDF Basics
1.RDF: Resource Description Framework (资源描述框架)
资源描述框架(Resource Description Framework, 简称 RDF)是一个用于表达关于万维网(World Wide Web)上的资源的信息的语言. 它专门用于表达关于Web资源的元数据, 比如Web页面的标题、作者和修改时间,Web文档的版权和许可信息,某个被共享资源的可用计划表等。
然而,将“Web资源(Web resource)”这一概念一般化后,RDF可被用于表达关于任何可在Web上被标识的事物的信息,即使有时它们不能被直接从Web上获取。比如关于一个在线购物机构的某项产品的信息(例如关于规格、价格和可用性信息),或者是关于一个Web用户在信息递送方面的偏好的描述。
l RDF不是用来给人读的,而是给计算机读.
l RDF文档都是XML文档.RDF使用的XML语言是RDF/XML.
2. RDF Resource, Property, and Property Value
RDF uses Web identifiers (URIs) to identify resources.
RDF describes resources with properties and property values.
l A Resource : 可以用URI来表示的东西, 如"http://www.w3schools.com/RDF"
l A Property is a Resource that has a name, such as "author" or "homepage"
l A Property value is the value of a Property, such as "Jan Egil Refsnes" or "http://www.w3schools.com" (note that a property value can be another resource)
3. RDF Statements
The combination of a Resource, a Property, and a Property value forms a Statement (known as the subject, predicate and object of a Statement).
e.g.
Statement: "The author of http://www.w3schools.com/RDF is Jan Egil Refsnes".
* The subject of the statement above is: http://www.w3schools.com/RDF
* The predicate is: author
* The object is: Jan Egil Refsnes
4. RDF Example
This is a few lines from a CD-list:
Title |
Artist |
Country |
Company |
Price |
Year |
Empire Burlesque |
Bob Dylan |
USA |
Columbia |
10.90 |
1985 |
Hide your heart |
Bonnie Tyler |
UK |
CBS Records |
9.90 |
1988 |
... |
|
|
|
|
|
This is a few lines of an RDF document:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">
<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
<cd:artist>Bob Dylan</cd:artist>
<cd:country>USA</cd:country>
<cd:company>Columbia</cd:company>
<cd:price>10.90</cd:price>
<cd:year>1985</cd:year>
</rdf:Description>
<rdf:Description
rdf:about="http://www.recshop.fake/cd/Hide your heart">
<cd:artist>Bonnie Tyler</cd:artist>
<cd:country>UK</cd:country>
<cd:company>CBS Records</cd:company>
<cd:price>9.90</cd:price>
<cd:year>1988</cd:year>
</rdf:Description>
.
.
.
</rdf:RDF>
|
<rdf:RDF>
RDF文档的根元素.把当前XML文档定义为RDF文档.
<rdf:Description>
使用about属性来标明一个resource.
5. RDF Container Elements
用来描述一组东西.如列举一本书的作者.这类元素有<Bag>, <Seq>和<Alt>,它们被成为container, 包含的值被成为member.
l <Bag>: 用来描述一组无序的值(可以有重复的值)
l <Seq>: 用来描述一组有序的值(可以有重复的值)
l <Alt>: 一组值,用户多选一,如:
<rdf:Alt>
<rdf:li>CD</rdf:li>
<rdf:li>Record</rdf:li>
<rdf:li>Tape</rdf:li>
</rdf:Alt>
6. RDF Collections
用来描述仅包含指定元素的组. Group元素里指定了member,但是并没有排斥其它的值.Collection属性确保一个组里只能包含指定的值.
e.g.
<rdf:Description
rdf:about="http://recshop.fake/cd/Beatles">
<cd:artist rdf:parseType="Collection">
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/George"/>
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/John"/>
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Paul"/>
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Ringo"/>
</cd:artist>
</rdf:Description>
7. RDFS (RDF Schema)
RDF Schema提供了描述应用程序相关的类和属性的框架.
e.g.
<?xml version="1.0"?> <rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base= "http://www.animals.fake/animals#"> <rdf:Description rdf:ID="animal"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="horse"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> <rdfs:subClassOf rdf:resource="#animal"/> </rdf:Description> </rdf:RDF> |
可以简写为:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base= "http://www.animals.fake/animals#"> <rdfs:Class rdf:ID="animal" /> <rdfs:Class rdf:ID="horse"> <rdfs:subClassOf rdf:resource="#animal"/> </rdfs:Class> </rdf:RDF> |
8. RDF Dublin Core Metadata Initiative(DCMI)
预定义的有些用来描述文档的属性, 如Title, Creator, Type, Language等,
命名空间是"http://purl.org/dc/elements/1.1/"
9 命名空间
The RDF namespace (xmlns:rdf) is:
http://www.w3.org/1999/02/22-rdf-syntax-ns#
The RDFS namespace (xmlns:rdfs ) is:
http://www.w3.org/2000/01/rdf-schema#
10 The RDF Extension and Mime Type
File Extension: .rdf
Mime type: application/rdf+xml
14 OWL(Web Ontology Language)
是一种用来处理网络信息的语言.
基于RDF
设计为方便机器处理,不方便人阅读
有3种子语言
11. Ontology
事物和它们之间关系的准确描述.对于网络来说,就是对网络信息和它们之间关系的准确描述.
12 OWL and RDF
OWL and RDF are much of the same thing, but OWL is a stronger language with greater machine interpretability than RDF.
OWL comes with a larger vocabulary and stronger syntax than RDF.
17 OWL has three sublanguages:
* OWL Lite
* OWL DL (includes OWL Lite)
* OWL Full (includes OWL DL)
18 Vocabulary
RDF称一个URIref的集合(特别是为了某个目的集合)为词汇表(vocabulary). 通常,这些词汇表中的URIrefs被组织为一个有相同前缀的QName的集合。
中英文对照
object 客体
predicate 谓词
RDF 资源描述框架
subject 主体
Reference
RDF Tutorial. W3school
http://www.w3schools.com/rdf/default.asp
W3C's RDF Validation Service
http://www.w3.org/RDF/Validator/
RDF Class, Property, Attribute列表
http://www.w3schools.com/rdf/rdf_reference.asp
RDF Primer(入门)中英文对照
http://zh.transwiki.org/cn/rdfprimer.htm
http://www.w3.org/TR/2004/REC-rdf-primer-20040210/
比较完整的入门资料