RDF中文翻译成:资源描述框架。
1.What is RDF?
- RDF stands for Resource Description Framework
- RDF is a framework for describing resources on the web
- RDF is designed to be read and understood by computers
- RDF is not designed for being displayed to people
- RDF is written in XML
- RDF is a part of the W3C's Semantic Web Activity
- RDF is a W3C Recommendation
2.RDF - Examples of Use
- Describing properties for shopping items, such as price and availability
- Describing time schedules for web events
- Describing information about web pages (content, author, created and modified date)
- Describing content and rating for web pictures
- Describing content for search engines
- Describing electronic libraries
3.RDF is Designed to be Read by Computers
RDF was designed to provide a common way to describe information so it can be read and understood by computer applications.
RDF descriptions are not designed to be displayed on the web.
4.RDF is Written in XML
RDF documents are written in XML. The XML language used by RDF is called RDF/XML.
By using XML, RDF information can easily be exchanged between different types of computers using different types of operating systems and application languages.
5.Application and explaination
RDF的基本思想很简单,就是说任何网络资源都可以唯一地用URI(统一资源标识符,Uniform Resource Identifier)来表示。在这里,可以简化地将URI理解成网址URL。
比如,世界第一大网站Yahoo!首页的网址是http://www.yahoo.com/,那么它的首页就可以用这个网址来唯一代表。
有了这个识别符以后,网络资源的其他特性都用“属性(Property)”=“属性值(Property value)”这样的形式来表示。
最顶部的方框表示网络资源http://www.yahoo.com/,下面的两个方框表示两个属性关系,一个是“资源作者=Yahoo!公司”,另一个是“资源名称=Yahoo!首页”。
根据RDF的定义,资源本身是主语subject,属性名称是谓语predicate,属性指是宾语object。对网络资源的描述就采用主-谓-宾的形式。
RDF本身用xml文件的形式表示,比如上图写成xml文件就是:
<?xml version="1.0"?>
<RDF>
<Description about="http://www.yahoo.com/">
<资源作者>Yahoo!公司</资源作者>
<资源名称>Yahoo!首页</资源名称>
</Description>
</RDF>
这个xml文件不是很规范,主要是为了说明问题。
RDF强大的地方在于,它只规定了主-谓-宾这种描述形式,至于谓语和宾语到底是什么,完全可以根据不同需要自由选用。因此,RDF才能定义为“资源描述框架”,而不是“资源描述方法”。
用于RDF的最常见谓语和宾语,是都柏林核心(Dublin Core),简称DC。它是一套用于描述信息的元数据,一共有15个标签,也就是15个谓语和宾语的组合,其中常见的标签包括Title,Creator,Subject等等。
采用了都柏林核心以后,基本上所有的网络资源都可以用RDF描述出来,因此初步实现了对网络资源进行编目的目的,为下一步机器化处理和最终语义网的实现打下了基础。
6.RDF Document Example
|
7.RDF Rules
RDF uses Web identifiers (URIs) to identify resources.
RDF describes resources with properties and property values.
RDF Resource, Property, and Property Value
RDF identifies things using Web identifiers (URIs), and describes resources with properties and property values.
Explanation of Resource, Property, and Property value:
- A Resource is anything that can have a URI, such as "http://www.w3schools.com/rdf"
- A Property is a Resource that has a name, such as "author" or "homepage"
- 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)
The following RDF document could describe the resource "http://www.w3schools.com/rdf":
<?xml version="1.0"?> <RDF> <Description about="http://www.w3schools.com/rdf"> <author>Jan Egil Refsnes</author> <homepage>http://www.w3schools.com</homepage> </Description> </RDF> |
8.RDF Example
Here are two records 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 |
Below is a few lines from 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> |
The first line of the RDF document is the XML declaration. The XML declaration is followed by the root element of RDF documents: <rdf:RDF>.
The xmlns:rdf namespace, specifies that elements with the rdf prefix are from the namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#".
The xmlns:cd namespace, specifies that elements with the cd prefix are from the namespace "http://www.recshop.fake/cd#".
The <rdf:Description> element contains the description of the resource identified by the rdf:about attribute.
The elements: <cd:artist>, <cd:country>, <cd:company>, etc. are properties of the resource.
8.RDF Online Validator
W3C's RDF Validation Service is useful when learning RDF. Here you can experiment with RDF files.
The online RDF Validator parses your RDF document, checks your syntax, and generates tabular and graphical views of your RDF document.
Copy and paste the example below into W3C's RDF validator:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:si="http://www.w3schools.com/rdf/"> <rdf:Description rdf:about="http://www.w3schools.com"> <si:title>W3Schools.com</si:title> <si:author>Jan Egil Refsnes</si:author> </rdf:Description> </rdf:RDF> |
When you parse the example above, the result will look something like this.
9.RDF Main Elements
The main elements of RDF are the root element, <RDF>, and the <Description> element, which identifies a resource.
The <rdf:RDF> Element
<rdf:RDF> is the root element of an RDF document. It defines the XML document to be an RDF document. It also contains a reference to the RDF namespace:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> ...Description goes here... </rdf:RDF> |
The <rdf:Description> Element
The <rdf:Description> element identifies a resource with the about attribute.
The <rdf:Description> element contains elements that describe the resource:
<?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:RDF> |
The elements, artist, country, company, price, and year, are defined in the http://www.recshop.fake/cd# namespace. This namespace is outside RDF (and not a part of RDF). RDF defines only the framework. The elements, artist, country, company, price, and year, must be defined by someone else (company, organization, person, etc).
Properties as Attributes
The property elements can also be defined as attributes (instead of elements):
<?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:country="USA" cd:company="Columbia" cd:price="10.90" cd:year="1985" /> </rdf:RDF> |
Properties as Resources
The property elements can also be defined as resources:
<?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 rdf:resource="http://www.recshop.fake/cd/dylan" /> ... ... </rdf:Description> </rdf:RDF> |
In the example above, the property artist does not have a value, but a reference to a resource containing information about the artist.
10.RDF Container Elements
RDF containers are used to describe group of things.
The following RDF elements are used to describe groups: <Bag>, <Seq>, and <Alt>.
The <rdf:Bag> Element
The <rdf:Bag> element is used to describe a list of values that does not has to be in a special order.
The <rdf:Bag> element may contain duplicate values.
Example
<?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/Beatles"> <cd:artist> <rdf:Bag> <rdf:li>John</rdf:li> <rdf:li>Paul</rdf:li> <rdf:li>George</rdf:li> <rdf:li>Ringo</rdf:li> </rdf:Bag> </cd:artist> </rdf:Description> </rdf:RDF> |
The <rdf:Seq> Element
The <rdf:Seq> element is used to describe an ordered list of values (For example, in alphabetical order).
The <rdf:Seq> element may contain duplicate values.
Example
<?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/Beatles"> <cd:artist> <rdf:Seq> <rdf:li>George</rdf:li> <rdf:li>John</rdf:li> <rdf:li>Paul</rdf:li> <rdf:li>Ringo</rdf:li> </rdf:Seq> </cd:artist> </rdf:Description> </rdf:RDF> |
The <rdf:Alt> Element
The <rdf:Alt> element is used to describe a list of alternative values (the user can select only one of the values).
Example
<?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/Beatles"> <cd:format> <rdf:Alt> <rdf:li>CD</rdf:li> <rdf:li>Record</rdf:li> <rdf:li>Tape</rdf:li> </rdf:Alt> </cd:format> </rdf:Description> </rdf:RDF> |
RDF Terms
In the examples above we have talked about "list of values" when describing the container elements. In RDF these "list of values" are called members.
So, we have the following:
- A container is a resource that contains things
- The contained things are called members (not list of values)
参考:
http://www.w3schools.com/
http://www.ruanyifeng.com