Resource Description Framework (RDF)
RDF Model and Syntax
- Language to describe resources
- Use metadata (data about data) to describe Web resources
- Provides interoperability between applications that exchange
machine-understandable information on the Web
- Use XML as a syntax
Application Areas
- Resource discovery - better search engine capabilities
- Cataloging - describe content and content relationship (web pages)
- Intelligent software agents - knowledge sharing
- Content Rating - PICS
- Collections of pages
- Intellectual property rights
- Privacy preferences and policies
- Digital signatures - build the "Web of Trust"
Basic RDF Model
Three object types:
- Resources - Things being described by RDF expressions. Resources are always named by URIs
- HTML Document
- Specific XML element within the document source.
- Collection of pages
- Book
- Properties - Specific aspect, characteristic, attribute or relation used
to describe a resource
- Statements - Resource (Subject) +
Property (Predicate) +
Property Value (Object)
Statement Example
John Punin is the creator of the web page http://www.cs.rpi.edu/~puninj/XMLJ/
- Subject (Resource) - http://www.cs.rpi.edu/~puninj/XMLJ/
- Predicate (Property) - Creator
- Object (Literal) - John Punin
Statement Example (2)
John Punin whose e-mail is puninj@cs.rpi.edu is the creator of the web page
http://www.cs.rpi.edu/~puninj/XMLJ
Basic Serialization Syntax
The RDF root element and namespace:
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
.
.
.
</rdf:RDF>
The RDF Description Element
- Attributes
- about - refers to a URI of an existing resource
- ID - signals the creation of a new resource
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
.
.
.
</rdf:Description>
</rdf:RDF>
RDF Property Elements
- Property names must be associated with a schema.
- Qualify property names with a namespace prefix
- Production propertyElt :
<PropertyName> Value </PropertyName>
- Value - Description element or String
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>John Punin</dc:creator>
</rdf:Description>
</rdf:RDF>
Describing Multiple Properties
- Describing creator, title and date of the resource
http://www.cs.rpi.edu/~puninj/XMLJ/
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>John Punin</dc:creator>
<dc:title>Programming XML in Java</dc:title>
<dc:date>2001-04-10</dc:date>
</rdf:Description>
</rdf:RDF>
Describing Multiple Resources
- Use multiple Description elements
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>John Punin</dc:creator>
<dc:title>Programming XML in Java</dc:title>
<dc:date>2001-04-10</dc:date>
</rdf:Description>
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XGMML/">
<dc:creator>John Punin</dc:creator>
<dc:title>Extensible Graph Markup and Modeling Language</dc:title>
<dc:date>2001-04-04</dc:date>
</rdf:Description>
</rdf:RDF>
Nesting Resources
- Values of properties are Description elements
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:vcard="http://imc.org/vCard/3.0#">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>
<rdf:Description>
<vcard:FN>John Punin</vcard:FN>
<vcard:EMAIL>puninj@cs.rpi.edu</vcard:EMAIL>
</rdf:Description>
</dc:creator>
</rdf:Description>
</rdf:RDF>
Referring to Resources by Reference
- Production propertyElt :
<PropertyName> Value </PropertyName> or
<PropertyName rdf:resource="URI" />
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:vcard="http://imc.org/vCard/3.0#">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator rdf:resource="http://www.cs.rpi.edu/students/puninj"/>
</rdf:Description>
<rdf:Description about="http://www.cs.rpi.edu/students/puninj">
<vcard:FN>John Punin</vcard:FN>
<vcard:EMAIL>puninj@cs.rpi.edu</vcard:EMAIL>
</rdf:Description>
</rdf:RDF>
Using XML in Property Elements
- Set parseType attribute to Literal
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description about="http://www.cs.rpi.edu/TR/tr01/">
<dc:title rdf:parseType="Literal">
Solving
<mrow>
<mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></mrow>
<mo>=</mo><mn>0</mn>
</mrow>
</dc:title>
<dc:date>2020-01-30</dc:date>
</rdf:Description>
<rdf:RDF>
Using Abbreviated RDF Syntax
First basic abbreviation syntax:
- Property elements converted to attributes
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>John Punin</dc:creator>
<dc:title>Programming XML in Java</dc:title>
<dc:date>2001-04-10</dc:date>
</rdf:Description>
</rdf:RDF>
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/"
dc:creator="John Punin" dc:title="Programming XML in Java"
dc:date="2001-04-10"/>
</rdf:RDF>
Using Abbreviated RDF Syntax (2)
Second basic abbreviation syntax:
- The inner Description element and its contained properties can be
written as attributes of the "creator" element
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:vcard="http://imc.org/vCard/3.0#">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>
<rdf:Description about="http://www.cs.rpi.edu/students/puninj">
<vcard:FN>John Punin</vcard:FN>
<vcard:EMAIL>puninj@cs.rpi.edu</vcard:EMAIL>
</rdf:Description>
</dc:creator>
</rdf:Description>
</rdf:RDF>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:vcard="http://imc.org/vCard/3.0#">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator rdf:resource="http://www.cs.rpi.edu/students/puninj"
vcard:FN="John Punin"
vcard:EMAIL="puninj@cs.rpi.edu"/>
</rdf:Description>
</rdf:RDF>
Using Abbreviated RDF Syntax (2)
Third basic abbreviation syntax:
- New fact:
http://www.cs.rpi.edu/~puninj/XMLJ/
is an instance of a WebPage
- rdf:type element adds this new fact
- value of the rdf:type can be used directly as element name
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<rdf:type rdf:resource="http://www.schemas.org/www/Webpage"/>
<dc:creator>John Punin</dc:creator>
<dc:title>Programming XML in Java</dc:title>
<dc:date>2001-04-10</dc:date>
</rdf:Description>
</rdf:RDF>
<?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:s="http://www.schemas.org/www/">
<s:WebPage about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>John Punin</dc:creator>
<dc:title>Programming XML in Java</dc:title>
<dc:date>2001-04-10</dc:date>
</s:WebPage>
</rdf:RDF>
RDF Containers
- Bag - An unordered list of resources or literals
- Sequence - An ordered list of resources or literals
- Alternative - A list of resources or literals that represent alternatives
for the value of a property
Using the Bag Container
Statement: The authors of the book 0201000237 are Alfred, John and Jeffrey
<?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 about="urn:ISBN:0-201-00023-7">
<dc:creator>
<rdf:Bag>
<rdf:li>Alfred</rdf:li>
<rdf:li>John</rdf:li>
<rdf:li>Jeffrey</rdf:li>
</rdf:Bag>
</dc:creator>
</rdf:Description>
</rdf:RDF>
Using the Seq Container
Statement: The students of the course csci-2962 in alphabetical order are
Elizabeth, George and John.
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://www.schemas.org/Course/">
<rdf:Description about="http://www.cs.rpi.edu/courses/csci-2962">
<s:students>
<rdf:Seq>
<rdf:li rdf:resource="http://www.cs.rpi.edu/students/er"/>
<rdf:li rdf:resource="http://www.cs.rpi.edu/students/gl"/>
<rdf:li rdf:resource="http://www.cs.rpi.edu/students/js"/>
</rdf:Seq>
</s:students>
</rdf:Description>
</rdf:RDF>
Using the Alt Container
Statement: The format of the book 0201000237 are plain text, html and postscript.
<?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 about="urn:ISBN:0-201-00023-7">
<dc:format>
<rdf:Alt>
<rdf:li>text/html</rdf:li>
<rdf:li>text/plain</rdf:li>
<rdf:li>application/postscript</rdf:li>
</rdf:Alt>
</dc:format>
</rdf:Description>
</rdf:RDF>
Making Statements about Containers
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://www.schemas.org/Course/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<s:homeworks>
<rdf:Bag ID="pages">
<rdf:li rdf:resource="http://www.cs.rpi.edu/~puninj/XMLJ/hw1.html">
<rdf:li rdf:resource="http://www.cs.rpi.edu/~puninj/XMLJ/hw2.html">
</rdf:Bag>
</s:homeworks>
</rdf:Description>
<rdf:Description about="#pages">
<dc:creator>John Punin</dc:creator>
</rdf:Description>
</rdf:RDF>
Making Statements about the Items in a Container
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://www.schemas.org/Course/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<s:homeworks>
<rdf:Bag ID="pages">
<rdf:li rdf:resource="http://www.cs.rpi.edu/~puninj/XMLJ/hw1.html"/>
<rdf:li rdf:resource="http://www.cs.rpi.edu/~puninj/XMLJ/hw2.html"/>
</rdf:Bag>
</s:homeworks>
</rdf:Description>
<rdf:Description aboutEach="#pages">
<dc:creator>John Punin</dc:creator>
</rdf:Description>
</rdf:RDF>
Statements about Statements
Using Reification
RDF defines the following properties:
- rdf:subject - The resource being described
- rdf:predicate - The original property
- rdf:object - The property value in the statement
- rdf:type - rdf:Statement
Gerard Uffelman says that John Punin is the creator of the web page
http://www.cs.rpi.edu/~puninj/XMLJ/
<?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:s="http://www.schemas.org/schema/">
<rdf:Description>
<rdf:subject rdf:resource="http://www.cs.rpi.edu/~puninj/XMLJ/"/>
<rdf:predicate rdf:resource="http://purl.org/dc/elements/1.1/creator"/>
<rdf:object>John Punin</rdf:object>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>
<s:attributedTo>Gerard Uffelman</s:attributedTo>
</rdf:Description>
</rdf:RDF>
Non-Binary Relations
- RDF data model only supports binary relations (relation between two resources)
- Solution: Use an intermediate resource with additional properties
Statement: The cost of the book 0201000237 is $45.00
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:s="http://www.schemas.org/Units/">
<rdf:Description about="urn:ISBN:0-201-00023-7">
<s:price rdf:parseType="Resource">
<rdf:value>45.00</rdf:value>
<s:units rdf:resource="http://www.schemas.org/Units/USdollar"/>
</s:price>
</rdf:Description>
</rdf:RDF>
The Dublin Core Metadata
- Facilitate discovery of electronic resources
- http://www.purl.org/dc/
(http://dublincore.org/)
- The defined Dublin Core properties are:
- contributor
- coverage
- creator
- date
- description
- format
- identifier
- language
- publisher
- relation
- rights
- source
- subject
- title
- type
- Types values used with the type element
- collection
- dataset
- event
- image
- interactive resource
- model
- party
- physical object
- place
- service
- software
- sound
- text
<?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 about="http://www.cs.rpi.edu/~puninj/XMLJ/">
<dc:creator>John Punin</dc:creator>
<dc:title>Programming XML in Java</dc:title>
<dc:description>Home Page of Programming XML in Java course</dc:description>
<dc:date>2001-04-10</dc:date>
<dc:format>text/html</dc:format>
<dc:identifier>http://www.cs.rpi.edu/~puninj/XMLJ/</dc:identifier>
<dc:subject>XML, Java, Computer Science Course</dc:subject>
<dc:publisher>RPI Computer Science Department</dc:publisher>
<dc:language>en</dc:language>
<dc:type>electronic document</dc:type>
</rdf:Description>
</rdf:RDF>
Content hiding for RDF inside HTML
- Use RDF abbreviated syntax
<html>
<head>
<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 about=""
dc:creator="John Punin"
dc:title="Programming XML in Java"
dc:date="2001-04-10"/>
</rdf:RDF>
<title>Programming XML in Java</title>
</head>
<body>
.
.
.
</body>
</html>
RDF Resources and Tools
RDF Schema
- Basic vocabulary to describe RDF vocabularies
- Defines properties of the resources (e.g., title, author, subject, etc)
- Defines kinds of resources being describes (books, Web pages, people, etc)
- XML Schema gives specific constraints on the structure of an XML document
- RDF Schema provides information about the interpretation of the RDF statements
RDF Classes and Properties
- Namespace prefix:'rdfs' URI:'http://www.w3.org/2000/01/rdf-schema#'
- Resources may be instances of one or more classes
- Indicated by rdf:type property
- Resource http://www.cs.rpi.edu/students/puninj is rdf:type Student
- Resource http://www.cs.rpi.edu/students/puninj is rdf:type Person
- Student is rdfs:subClassOf Person
- Property-centric approach
- Define properties in terms of the classes of resource to which they apply
RDF Core Classes
- rdfs:Resource - resources are instances of this class
- rdf:Property - properties are instances of this class
- rdfs:Class - similar to a Class in object-oriented programming language.
RDF Core Properties
- rdf:type - indicates that a resource is a member of a class
- rdfs:subClassOf - specifies subset/superset relation between classes
- rdfs:subPropertyOf - specifies that a property is a specialization of another
- rdfs:seeAlso - specifies a resource that provides additional information
- rdfs:isDefinedBy - indicates the resource defining the subject resource
RDF Constraints
- rdfs:range
- Indicate the classes that the values of a property must be members.
- The value of a range property is a rdf:Class
- rdfs:domain
- Indicate the classes on whose members a property can be used.
- No domain property means that the property may be used with any resource.
RDF Documentation
- rdfs:comment - human-readable description of a resource
- rdfs:label - human-readable version of a resource name
RDF Schema 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#">
<rdfs:Class rdf:ID="Person">
<rdfs:comment>Person Class</rdfs:comment>
<rdfs:subClassOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource"/>
</rdfs:Class>
<rdfs:Class rdf:ID="Student">
<rdfs:comment>Student Class</rdfs:comment>
<rdfs:subClassOf rdf:resource="#Person"/>
</rdfs:Class>
<rdfs:Class rdf:ID="Teacher">
<rdfs:comment>Teacher Class</rdfs:comment>
<rdfs:subClassOf rdf:resource="#Person"/>
</rdfs:Class>
<rdfs:Class rdf:ID="Course">
<rdfs:comment>Course Class</rdfs:comment>
<rdfs:subClassOf rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource"/>
</rdfs:Class>
<rdf:Property rdf:ID="teacher">
<rdfs:comment>Teacher of a course</rdfs:comment>
<rdfs:domain rdf:resource="#Course"/>
<rdfs:range rdf:resource="#Teacher"/>
</rdf:Property>
<rdf:Property rdf:ID="students">
<rdfs:comment>List of Students of a course in alphabetical order</rdfs:comment>
<rdfs:domain rdf:resource="#Course"/>
<rdfs:range rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq"/>
</rdf:Property>
<rdf:Property rdf:ID="name">
<rdfs:comment>Name of a Person or Course</rdfs:comment>
<rdfs:domain rdf:resource="#Person"/>
<rdfs:domain rdf:resource="#Course"/>
<rdfs:range rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Literal"/>
</rdf:Property>
</rdf:RDF>
RDF Example
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#">
<Course rdf:ID="csci_2962">
<name>Programming XML in Java</name>
<teacher>
<Teacher rdf:ID="jp">
<name>John Punin</name>
</Teacher>
</teacher>
<students>
<rdf:Seq>
<rdf:li>
<Student rdf:ID="er">
<name>Elizabeth Roberts</name>
</Student>
</rdf:li>
<rdf:li>
<Student rdf:ID="gl">
<name>George Lucas</name>
</Student>
</rdf:li>
<rdf:li>
<Student rdf:ID="js">
<name>John Smith</name>
</Student>
</rdf:li>
</rdf:Seq>
</students>
</Course>
</rdf:RDF>
Triples of the RDF Example
- Using Sirpac
Triples of the data model : number (subject, predicate, object)
1 (online:#csci_2962, http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#Course)
2 (online:#csci_2962,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#name Programming,
XML in Java)
3 (online:#jp, http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#Teacher)
4 (online:#jp, http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#name,
John Punin)
5 (online:#csci_2962,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#teacher,
online:#jp)
6 (online:#genid5, http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq)
7 (online:#er, http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#Student)
8 (online:#er,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#name,
Elizabeth Roberts)
9 (online:#genid5, http://www.w3.org/1999/02/22-rdf-syntax-ns#_1,
online:#er)
10 (online:#gl, http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#Student)
11 (online:#gl,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#name, George Lucas)
12 (online:#genid5, http://www.w3.org/1999/02/22-rdf-syntax-ns#_2,
online:#gl)
13 (online:#js, http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#Student)
14 (online:#js, http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#name,
John Smith)
15 (online:#genid5, http://www.w3.org/1999/02/22-rdf-syntax-ns#_3,
online:#js)
16 (online:#csci_2962,
http://www.cs.rpi.edu/~puninj/XMLJ/course_schema.rdf#students,
online:#genid5)
The number of triples = 16