170 likes | 500 Views
Introduction to RDF. Based on tutorial at www.w3schools.com. Resource Description Framework. A framework (not a language) for describing resources Model for data Syntax to allow exchange and use of information stored in various locations
E N D
Introduction to RDF Based on tutorial at www.w3schools.com
Resource Description Framework • A framework (not a language) for describing resources • Model for data • Syntax to allow exchange and use of information stored in various locations • The point is to facilitate reading and correct use of information by computers, not necessarily by people
w3c recommendation • Find the official recommendation at http://www.w3.org/RDF/s • Note the subtle difference between a standard and a recommendation • w3c has no power to enforce compliance. • Obeying the rules in the recommendation allows a site to participate in the world wide web cooperative enterprise.
Identification and description • RDF identifies resources with URIs • Often, though not always, the same as a URL • Anything that can have a URI is a RESOURCE • RDF describes resources with properties and property values • A property is a resource that has a name • Ex. Author, Book, Address, Client, Product • A property value is the value of the Property • Ex. “Joanna Santillo,” http://www.someplace.com/, etc. • A property value can be another resource, allowing nested descriptions.
Statements • Resource, Property, Property Value • Aka subject, predicate, object of a statement • Predicates are not the same as English language verbs. • Specify a relationship between the subject and the object
Statement: "The author of http://www.w3schools.com/RDF is Jan Egil Refsnes". Subject: http://www.w3schools.com/RDF Predicate: author Object: Jan Egil Refsnes Statement: "The homepage of http://www.w3schools.com/RDF is http://www.w3schools.com". Subject: http://www.w3schools.com/RDF Predicate: homepage Object: http://www.w3schools.com Examples
RDF offers only binary predicates. Think of them as P(x,y) where P is the relationship between the objects x and y. From the example, X = http://www.w3schools.com/RDF Y = Jan Egil Refsnes P = author Binary predicates http://www.w3schools.com/RDF Jan Egil Refsnes author
<?xml version="1.0"?><rdf:RDFxmlns: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>. Root element of RDF documents Source of namespace for elements with rdf prefix Source of namespace for elements with cd prefix Description element describes the resource identified by the rdf:about attribute. Cd:country etc are properties of the resource.
RDF validator • Check the correctness of an RDF document: • http://www.w3.org/RDF/Validator/ • Result shows the subject, predicate and object of each element of the document and a graph of the model.
Containers • Groups of things: <bag> <seq> <alt> • <bag> unordered list; duplicates allowed • <seq> ordered list; duplicates allowed • <alt> list of alternatives; one will be selected
Example <alt> <?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> Exactly one of these formats
Limiting the scope • Collection - describes a group that contains only the specified members, no others. <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>
RDF Schema • Extension to RDF to allow definition of application-specific classes and properties • Does not define the classes, properties. • Provides a framework to describe such • Classes - similar to OOP • Allows instances and subclasses of classes.
<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> Horse defined as subclass of animal
<?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> Abbreviated version. Works because an RDFS class is an RDF resource. Use rdfs:Class instead of rdfDescription and drop the rdf:type information
Dublin Core • RDF is metadata -- data about data • Dublin core is a set of properties for describing documents • See www.dublincore.org for details • 15 basic elements: • Contributor, coverage, creator, format, date, description, identifier, language, publisher, relation, rights, source, subject, title, type