RDF Tutorial
RDF Tutorial
RDF Tutorial
Introduction to RDF
The Resource Description Framework (RDF) is a W3C standard for describing Web resources, such as the
title, author, modification date, content, and copyright information of a Web page.
If you want to study these subjects first, find the tutorials on our Home page.
What is RDF?
RDF stands for Resource Description Framework
RDF is a framework for describing resources on the web
RDF provides a model for data, and a syntax so that independent parties can exchange and use it
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
By using XML, RDF information can easily be exchanged between different types of computers using
different types of operating systems and application languages.
RDF and "The Semantic Web"
The RDF language is a part of the W3C's Semantic Web Activity. W3C's "Semantic Web
Vision" is a future where:
Web information has exact meaning
Web information can be understood and processed by computers
Computers can integrate information from the web
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.
1
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>
The example above is simplified. Namespaces are omitted.
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).
Let's look at some example statements to get a better understanding:
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
Statement: "The homepage of http://www.w3schools.com/RDF is http://www.w3schools.com".
The subject of the statement above is: http://www.w3schools.com/RDF
The predicate is: homepage
The object is: http://www.w3schools.com
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
...
2
</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.
When you parse the example above, the result will look something like this.
1: <?xml version="1.0"?>
2: <rdf:RDF
3: xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
4: xmlns:si="http://www.recshop.fake/siteinfo#">
5: <rdf:Description rdf:about="http://www.w3schools.com/RDF">
6: <si:author>Jan Egil Refsnes</si:author>
7: <si:homepage>http://www.w3schools.com</si:homepage>
8: </rdf:Description>
9: </rdf:RDF>
3
The main elements of RDF are the root element, <RDF>, and the <Description> element, which identifies a
resource.
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
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>
4
</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.
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#"
5
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.
RDF Collections
RDF collections are used to describe groups that contains ONLY the specified members.
The rdf:parseType="Collection" Attribute
As seen in the previous chapter: You cannot close a container. A container says that the containing
resources are members - it does not say that other members are not allowed.
RDF collections are used to describe group that contains ONLY the specified members.
6
RDFS Example
The following example demonstrates some of the RDFS facilities:
<?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>
In the example above, the resource "horse" is a subclass of the class "animal".
Example Abbreviated
Since an RDFS class is an RDF resource we can abbreviate the example above by using rdfs:Class instead
of rdf:Description, and drop the rdf:type information:<?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>
That's it!
Property Definition
7
Description An account of the content of the resource
A quick look at the table above indicates that RDF is ideal for representing Dublin Core information.
RDF Example
The following example demonstrates the use of some of the Dublin Core properties in an RDF document:<?
xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc= "http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="http://www.w3schools.com">
<dc:title>D-Lib Program</dc:title>
<dc:description>W3Schools - Free tutorials</dc:description>
<dc:publisher>Refsnes Data as</dc:publisher>
<dc:date>1999-09-01</dc:date>
<dc:type>Web Development</dc:type>
<dc:format>text/html</dc:format>
<dc:language>en</dc:language>
</rdf:Description>
</rdf:RDF>
Introduction to OWL
OWL is a language for processing web information.
What is OWL?
OWL stands for Web Ontology Language
OWL is built on top of RDF
OWL is for processing information on the web
OWL was designed to be interpreted by computers
OWL was not designed for being read by people
OWL is written in XML
OWL has three sublanguages
8
OWL is a W3C standard
What is Ontology?
Ontology is about the exact description of things and their relationships.
For the web, ontology is about the exact description of web information and relationships between web
information.
Why OWL?
OWL is a part of the "Semantic Web Vision" - a future where:
Web information has exact meaning
Web information can be processed by computers
Computers can integrate information from the web
OWL was Designed for Processing Information
OWL was designed to provide a common way to process the content of web information (instead of
displaying it).
OWL was designed to be read by computer applications (instead of humans).
OWL Sublanguages
OWL has three sublanguages:
OWL Lite
OWL DL (includes OWL Lite)
OWL Full (includes OWL DL)
OWL is Written in XML
By using XML, OWL information can easily be exchanged between different types of computers using
different types of operating system and application languages.
Class: Airport
Properties:
elevation
iataCode
icaoCode
latitude
location
longitude
name
Produced using dumpont2.java
RDF Reference
The RDF Namespaces
9
The recommended extension for RDF files is *.rdf. However, the extension *.xml is often used to provide
compatibility with older xml parsers.
The registered mime type should be "application/rdf+xml".
10
rdf:subject Statement Resource The subject of the resource in an RDF
Statement
rdf:predicate Statement Resource The predicate of the resource in an RDF
Statement
rdf:object Statement Resource The object of the resource in an RDF
Statement
rdf:value Resource Resource The property used for values
rdf:type Resource Class The resource is an instance of a class
RDF Attributes
Element Domain Range Description
rdf:aboutEach (removed)
rdf:aboutEachPrefix (removed)
rdf:bagID (removed)
Element Domain Range Description
Elements described as (removed) are removed from the latest RDF standard.
By: DataIntegratedEntity22592
Source: http://w3schools.com/rdf/default.asp
11