230 likes | 409 Views
RDF Tutorial. What is RDF?. RDF stands for Resource Description Framework It is used for describing resources on the web Makes use of URIs to identify web resources and is written in XML RDF is a web standard. Designed to be read by Computers.
E N D
What is RDF? • RDF stands for Resource Description Framework • It is used for describing resources on the web • Makes use of URIs to identify web resources and is written in XML • RDF is a web standard RDF Tutorial
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. RDF Tutorial
Makes use of URIs • RDF uses a URI (Uniform Resource Identifier) to identify a web resource, and properties to describe the resource • Unlike URLs, URIs are not limited to identifying things that have a network location • A URI reference (URIref) is a URI, together with an optional fragment identifier at the end. http://www.example.org/index.html#section2 RDF Tutorial
Simple Example <?xml version="1.0"?> <RDF> <Description about="http://www.w3schools.com/default.asp"> <author>Jan Egil Refsnes</author> <created>November 1, 1999</created> <modified>February 1, 2004</modified> </Description> </RDF> RDF Tutorial
Example explained • In the example: • the URI "http://www.w3schools.com/-default.asp" is used to identify a web page, • the property "author" describes the author of the page, • the property value is "Jan Egil Refsnes". • The property "created" tells when the page was created, and the property "modified" when it was last modified. RDF Tutorial
Subject, Predicate & Object • RDF terminology also use the words subject, predicate and object. • The resource http://www.w3schools.com/default.asp is the subject • The property "author" is the predicate • The value "Jan Egil Refsnes" is the object RDF Tutorial
Example 2 <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 Tutorial
Example 2 (cont) <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 Tutorial
Number Subject Predicate Object 1 http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdartist "Bob Dylan" 2 http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdcountry "USA" 3 http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdcompany "Columbia" 4 http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdprice "10.90" 5 http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdyear "1985" List of Triples RDF Tutorial
Directed Graph Representation Using RDF Validator: http://www.w3.org/RDF/Validator/ RDF Tutorial
Details of Example 2 • The first line in the XML file is the XML declaration, telling the version of XML. • The rdf:RDF element indicates that the content is RDF. • The xmlns:rdf namespace, specifies that tags with the rdf: prefix are from the namespace defined by "http://www.w3.org/1999/02/22-rdf-syntax-ns#". • The xmlns:cd namespace, specifies that tags with the cd: prefix are from the namespace defined by "http://www.recshop.fake/cd". • The rdf:Description element contains the description of a resource identified by the rdf:about attribute. • The cd:artist element describes a property of the resource, and so does cd:country, etc. RDF Tutorial
Main Elements • The RDF Element <rdf:RDF> • The RDF element is the root of the RDF document. It defines the XML document to be an RDF document and contains a reference to the xmlns: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 root element must always have a reference to the RDF namespace: http://www.w3.org/1999/02/22-rdf-syntax-ns# RDF Tutorial
Main Elements (cont) • The Description Element <rdf:Description> • The Description element describes a resource. • The about attribute identifies the resource. • Property elements are used to describe the resource • In example 2: The property elements (artist, country, company, price, and year) are defined in the namespace xmln:cd. RDF Tutorial
RDF Container Elements • The Bag Element <rdf:Bag> • The Bag element contains an unordered list of value elements • The Seq Element <rdf:Seq> • The Seq element contains an ordered list of value elements • The Alt Element <rdf:Alt> • The Alt element contains a list of alternative values for an element RDF Tutorial
rdf:Bag <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 Tutorial
rdf:Bag graph RDF Tutorial
RDF Collections • An RDF collection is a group of things represented as a list structure in the RDF graph. • A list structure constructed using a predefined collection vocabulary consisting of • predefined type rdf:List, • predefined properties rdf:first and rdf:rest, • predefined resource rdf:nil. • In RDF/XML, a collection can be described by a property element that has the attribute rdf:parseType="Collection", and that contains a group of nested elements representing the members of the collection. RDF Tutorial
RDF Collections RDF/XML <rdf:Description rdf:about="http://example.org/courses/6.001"> <s:students rdf:parseType="Collection"> <rdf:Description rdf:about="http://example.org/students/Amy"/> <rdf:Description rdf:about="http://example.org/students/Mohamed"/> <rdf:Description rdf:about="http://example.org/students/Johann"/> </s:students> </rdf:Description> RDF Tutorial
RDF Collections Graph RDF Tutorial
RDF Schema • RDF Schema provides the framework to describe application-specific classes and properties • Classes in RDF Schema are much like classes in object oriented programming languages. This allows resources to be defined as instances of classes, and subclasses of classes RDF Tutorial
RDFS example <?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> <rdfs:Class rdf:ID="dog"> <rdfs:subClassOf rdf:resource="#animal"/> </rdfs:Class> </rdf:RDF> RDF Tutorial
Next lectureIntroduction to OWL RDF Tutorial