2008-12-24
Tyng-Ruey Chuang
trc@iis.sinica.edu.tw
Institute of Information Science
Academia Sinica, Taipei, Taiwan
http://www.w3.org/People/EM/contact#me
, whose name is
Eric Miller, whose email address is em@w3.org, and whose title is
Dr.".http://www.w3.org/People/EM/contact#me
, whose name is
Eric Miller, whose email address is em@w3.org, and whose title is
Dr.".<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"> <contact:Person rdf:about="http://www.w3.org/People/EM/contact#me"> <contact:fullName>Eric Miller</contact:fullName> <contact:mailbox rdf:resource="mailto:em@w3.org"/> <contact:personalTitle>Dr.</contact:personalTitle> </contact:Person> </rdf:RDF>
http://www.example.org/index.html has a creator whose value is John Smith
http://www.example.org/index.html has a creator whose value is John Smith
http://www.example.org/index.html
http://www.example.org/index.html#section2
consists of the URI http://www.example.org/index.html
and (separated by the "#" character) the fragment identifier
Section2
.
http://www.example.org/index.html has a creator whose value is John Smith
http://www.example.org/index.html has a creation-date whose value is August 16, 1999
http://www.example.org/index.html has a language whose value is English
<http://www.example.org/index.html> <http://purl.org/dc/elements/1.1/creator> <http://www.example.org/staffid/85740> . <http://www.example.org/index.html> <http://www.example.org/terms/creation-date> "August 16, 1999" . <http://www.example.org/index.html> <http://purl.org/dc/elements/1.1/language> "en" .
ex:index.html dc:creator exstaff:85740 . ex:index.html exterms:creation-date "August 16, 1999" . ex:index.html dc:language "en" .
rdf:
, namespace URI:
http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs:
, namespace URI:
http://www.w3.org/2000/01/rdf-schema#
dc:
, namespace URI:
http://purl.org/dc/elements/1.1/
owl:
, namespace URI:
http://www.w3.org/2002/07/owl#
xsd:
, namespace URI:
http://www.w3.org/2001/XMLSchema#
ex:
, namespace URI:
http://www.example.org/
exterms:
, namespace URI:
http://www.example.org/terms/
exstaff:
, namespace URI:
http://www.example.org/staffid/
dc:
is associated with the namespace
URIref http://purl.org/dc/elements/1.1/
. This again
refers to the Dublin Core vocabulary: Accessing this namespace URIref
in a Web browser will retrieve additional information about the
Dublin Core vocabulary (in this case, an RDF schema).Advantages of using URIrefs as RDF's basic way of identifying things (using the following RDF graph as an example):
http://www.example.org/staffid/85740
.Note that RDF uses URIrefs as predicates in RDF statements. That is, rather than using character strings such as "creator" or "name" to identify properties, RDF uses URIrefs. Using URIrefs to identify properties has several advantages:
Using URIrefs as subjects, predicates, and objects in RDF statements supports the development and use of shared vocabularies on the Web.
For this reason, it is a good idea to try to use terms from existing vocabularies (such as the Dublin Core) where possible, rather than making up new terms that might overlap with those of some other vocabulary.
A person's whole address could be written out as a plain literal, as in the following triple:
exstaff:85740 exterms:address "1501 Grant Avenue, Bedford, Massachusetts 01730" .
What if the address needed to be recorded as a structure consisting of separate street, city, state, and postal code values? This is solved in RDF by the following:
exstaff:85740 exterms:address exaddressid:85740 . exaddressid:85740 exterms:street "1501 Grant Avenue" . exaddressid:85740 exterms:city "Bedford" . exaddressid:85740 exterms:state "Massachusetts" . exaddressid:85740 exterms:postalCode "01730" .
exstaff:85740 exterms:address _:johnaddress . _:johnaddress exterms:street "1501 Grant Avenue" . _:johnaddress exterms:city "Bedford" . _:johnaddress exterms:state "Massachusetts" . _:johnaddress exterms:postalCode "01730" .
An RDF typed literal is formed by pairing a string with a URIref that identifies a particular datatype. The value represented by the typed literal is the value that the specified datatype associates with the specified string. The datatypes used in typed literals are defined externally to RDF, and identified by their datatype URIs.
Example:
Triple notation:
<http://www.example.org/staffid/85740> <http://www.example.org/terms/age> "27"^^<http://www.w3.org/2001/XMLSchema#integer> .
Or, using the QName abbreviation:
exstaff:85740 exterms:age "27"^^xsd:integer .
A RDF graph:
Its RDF/XML presentation:
<?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/" xmlns:exterms="http://www.example.org/terms/"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>August 16, 1999</exterms:creation-date> </rdf:Description> <rdf:Description rdf:about="http://www.example.org/index.html"> <dc:language>en</dc:language> </rdf:Description> <rdf:Description rdf:about="http://www.example.org/index.html"> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:Description> </rdf:RDF>
An abbreviation:
<?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/" xmlns:exterms="http://www.example.org/terms/"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>August 16, 1999</exterms:creation-date> <dc:language>en</dc:language> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:Description> </rdf:RDF>
A RDF graph:
Its RDF/XML presentation:
<?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/" xmlns:exterms="http://example.org/stuff/1.0/"> <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"> <dc:title>RDF/XML Syntax Specification (Revised)</dc:title> <exterms:editor rdf:nodeID="abc"/> </rdf:Description> <rdf:Description rdf:nodeID="abc"> <exterms:fullName>Dave Beckett</exterms:fullName> <exterms:homePage rdf:resource="http://purl.org/net/dajobe/"/> </rdf:Description> </rdf:RDF>
A triple with typed literal:
ex:index.html exterms:creation-date "1999-08-16"^^xsd:date .
Its RDF/XML presentation:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.org/terms/"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date rdf:datatype= "http://www.w3.org/2001/XMLSchema#date">1999-08-16 </exterms:creation-date> </rdf:Description> </rdf:RDF>
Abbreviation using internal DTD subset:
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.org/terms/"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date rdf:datatype="&xsd;date">1999-08-16 </exterms:creation-date> </rdf:Description> </rdf:RDF>
An Example:
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.com/terms/" xml:base="http://www.example.com/2002/04/products"> <rdf:Description rdf:ID="item10245"> <exterms:model rdf:datatype="&xsd;string">Overnighter</exterms:model> <exterms:sleeps rdf:datatype="&xsd;integer">2</exterms:sleeps> <exterms:weight rdf:datatype="&xsd;decimal">2.4</exterms:weight> <exterms:packedSize rdf:datatype="&xsd;integer">784</exterms:packedSize> </rdf:Description> </rdf:RDF>
The above statement (the rdf:Description
element) talks
about the resource located at
http://www.example.com/2002/04/products#item10245
.
What a RDF resource is described with a predefined rdf:type
property,
the value of that property is considered to be a resource that
represents a category or class of things, and the
subject of that property is considered to be an
instance of that category or class.
An example:
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.com/terms/" xml:base="http://www.example.com/2002/04/products"> <rdf:Description rdf:ID="item10245"> <rdf:type rdf:resource="http://www.example.com/terms/Tent"/> <exterms:model rdf:datatype="&xsd;string">Overnighter</exterms:model> <exterms:sleeps rdf:datatype="&xsd;integer">2</exterms:sleeps> <exterms:weight rdf:datatype="&xsd;decimal">2.4</exterms:weight> <exterms:packedSize rdf:datatype="&xsd;integer">784</exterms:packedSize> </rdf:Description> </rdf:RDF>
Resource http://www.example.com/2002/04/products#item10245
is an instance of
the class http://www.example.com/terms/Tent
. Note that a class
is in itself a resource.
It is fairly common in RDF for resources to have rdf:type
properties that describe the resources as instances of specific types
or classes. Such resources are called typed nodes in the
graph, or typed node elements in the RDF/XML.
RDF/XML provides a special abbreviation for describing
these typed nodes. In this abbreviation, the
rdf:type
property and its value are removed, and the
rdf:Description
element for the node is replaced by an element
whose name is the QName corresponding to the value of the
removed rdf:type
property (a URIref that names a class).
The previous example, in abbreviation :
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.com/terms/" xml:base="http://www.example.com/2002/04/products"> <exterms:Tent rdf:ID="item10245"> <exterms:model rdf:datatype="&xsd;string">Overnighter</exterms:model> <exterms:sleeps rdf:datatype="&xsd;integer">2</exterms:sleeps> <exterms:weight rdf:datatype="&xsd;decimal">2.4</exterms:weight> <exterms:packedSize rdf:datatype="&xsd;integer">784</exterms:packedSize> </exterms:Tent> </rdf:RDF>
RDF provides a container vocabulary for describing things in groups. A container is a resource that contains other things (called members). The members of a container may be resources or literals.
RDF defines three types of containers:
rdf:Bag
— A Bag represents
a group of resources or literals, possibly including duplicate
members, where there is no significance in the order of the
members.rdf:Seq
— A Sequence represents
a group of resources or literals, possibly
including duplicate members, where the order of the members is
significant.rdf:Alt
— An Alternative
a group of resources or literals that
are alternatives (typically for a single value of a
property).
"Course 6.001 has the students Amy, Mohamed, Johann, Maria, and Phuong":
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:s="http://example.org/students/vocab#"> <rdf:Description rdf:about="http://example.org/courses/6.001"> <s:students> <rdf:Bag> <rdf:li rdf:resource="http://example.org/students/Amy"/> <rdf:li rdf:resource="http://example.org/students/Mohamed"/> <rdf:li rdf:resource="http://example.org/students/Johann"/> <rdf:li rdf:resource="http://example.org/students/Maria"/> <rdf:li rdf:resource="http://example.org/students/Phuong"/> </rdf:Bag> </s:students> </rdf:Description> </rdf:RDF>
Note that, in forming the corresponding graph, the the numbered
properties rdf:_1
, rdf:_2
, and so on are
generated from the rdf:li
elements:
RDF Schema provides the facilities needed to describe application-specific classes and properties, and to indicate which classes and properties are expected to be used together.
RDF Schema provides a type system for RDF. The RDF Schema type system is similar in some respects to the type systems of object-oriented programming languages. That is, it allows resources to be defined as instances of one or more classes. In addition, it allows classes to be organized in a hierarchical fashion.
The RDF Schema facilities are themselves provided in the form of
an RDF vocabulary; that is, as a specialized set of predefined RDF
resources with their own special meanings. The resources in the
RDF Schema vocabulary have URIrefs with the prefix
http://www.w3.org/2000/01/rdf-schema#
(conventionally
associated with the QName prefix rdfs:
).
In RDF Schema, a class is any resource having an
rdf:type
property whose value is the
resource rdfs:Class
.
Often a class to be described is a specialization of an existing class.
This kind of relationship between the
two classes is described using the predefined rdfs:subClassOf
property.
An example (in triple notation):
ex:MotorVehicle rdf:type rdfs:Class . ex:PassengerVehicle rdf:type rdfs:Class . ex:Van rdf:type rdfs:Class . ex:Truck rdf:type rdfs:Class . ex:MiniVan rdf:type rdfs:Class . ex:PassengerVehicle rdfs:subClassOf ex:MotorVehicle . ex:Van rdfs:subClassOf ex:MotorVehicle . ex:Truck rdfs:subClassOf ex:MotorVehicle . ex:MiniVan rdfs:subClassOf ex:Van . ex:MiniVan rdfs:subClassOf ex:PassengerVehicle .
The RDF model:
In RDF Schema, properties are
described using the RDF class rdf:Property
,
and the RDF Schema properties rdfs:domain
,
rdfs:range
, and rdfs:subPropertyOf
.
All properties in RDF are described as instances of class
rdf:Property
.
The rdfs:range
property is used to indicate that
the values of a particular property are instances of a
designated class.
The rdfs:domain
property is used to indicate that a
particular property applies to a designated class.
RDF Schema provides a way to specialize properties
as well as classes. This specialization
relationship between two properties is described using the predefined
rdfs:subPropertyOf
property.
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <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://example.org/schemas/vehicles"> <rdfs:Class rdf:ID="MotorVehicle"/> <rdfs:Class rdf:ID="PassengerVehicle"> <rdfs:subClassOf rdf:resource="#MotorVehicle"/> </rdfs:Class> <rdfs:Class rdf:ID="Truck"> <rdfs:subClassOf rdf:resource="#MotorVehicle"/> </rdfs:Class> <rdfs:Class rdf:ID="Van"> <rdfs:subClassOf rdf:resource="#MotorVehicle"/> </rdfs:Class> <rdfs:Class rdf:ID="MiniVan"> <rdfs:subClassOf rdf:resource="#Van"/> <rdfs:subClassOf rdf:resource="#PassengerVehicle"/> </rdfs:Class> <rdfs:Class rdf:ID="Person"/> <rdfs:Datatype rdf:about="&xsd;integer"/> <rdf:Property rdf:ID="registeredTo"> <rdfs:domain rdf:resource="#MotorVehicle"/> <rdfs:range rdf:resource="#Person"/> </rdf:Property> <rdf:Property rdf:ID="rearSeatLegRoom"> <rdfs:domain rdf:resource="#PassengerVehicle"/> <rdfs:range rdf:resource="&xsd;integer"/> </rdf:Property> <rdf:Property rdf:ID="driver"> <rdfs:domain rdf:resource="#MotorVehicle"/> </rdf:Property> <rdf:Property rdf:ID="primaryDriver"> <rdfs:subPropertyOf rdf:resource="#driver"/> </rdf:Property> </rdf:RDF>
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://example.org/schemas/vehicles#" xml:base="http://example.org/things"> <ex:PassengerVehicle rdf:ID="johnSmithsCar"> <ex:registeredTo rdf:resource="http://www.example.org/staffid/85740"/> <ex:rearSeatLegRoom rdf:datatype="&xsd;integer">127</ex:rearSeatLegRoom> <ex:primaryDriver rdf:resource="http://www.example.org/staffid/85740"/> </ex:PassengerVehicle> </rdf:RDF>