Download presentation
Presentation is loading. Please wait.
Published byStewart George Modified over 9 years ago
1
RDF Syntax and examples ดร. มารุต บูรณรัช marut.bur@nectec.or.th marut.bur@nectec.or.th 269618: หัวข้อพิเศษด้านเทคโนโลยีสารสนเทศขั้นสูง - เทคโนโลยีเว็บเชิงความหมาย (Special Topics in Advanced Information Technology – Semantic Web Technology) ภาควิชาวิทยาการคอมพิวเตอร์และเทคโนโลยีสารสนเทศ คณะวิทยาศาสตร์ มหาวิทยาลัยนเรศวร ภาคการศึกษาที่ 2 ปีการศึกษา 2557
2
RDF Syntax RDF Graph RDF/XML N-Triples Turtle (Terse RDF Triple Language) 2
3
Examples Adding triple with object as a resource Adding triple with object as literal (string) Adding triple with object as literal (integer) Adding triple with “rdf:type” property Adding triple for the same property with different values Different syntaxes for “rdf:about”, “rdf:ID”, “rdf:type” 3
4
Adding triple with object as a resource
5
Example RDF Triple “John Doe is a father of Jack Doe” Subjecthttp://www.mydomain.com/person#john_doe Predicatehttp://www.mydomain.com/vocab#father-of Objecthttp://www.mydomain.com/person#jack_doe 5
6
RDF Graph http://www.mydomain.com/person#john_doe http://www.mydomain.com/person#jack_doe http://www.mydomain.com/vocab#father-of 6
7
RDF/XML <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> 7
8
N-Triples. 8
9
Turtle @prefix x:. @prefix person:. person:john_doe x:father-of person:jack_doe. 9
10
Adding triple with object as literal (string)
11
Adding new triple Subjecthttp://www.mydomain.com/person#john_doe Predicatehttp://www.mydomain.com/vocab#has_name Object“John Doe”@en Note: “@” is optional for specifying language code of a string. 11
12
RDF Graph http://www.mydomain.com/person#john_doe http://www.mydomain.com/person#jack_doe http://www.mydomain.com/vocab#father-of “John Doe”@en http://www.mydomain.com/vocab#has_name 12
13
RDF/XML <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> John Doe 13
14
N-Triples. "John Doe" @en. 14
15
Turtle @prefix x:. @prefix person:. person:john_doe x:father-of person:jack_doe ; x:has_name "John Doe"@en. 15
16
Adding triple with object as literal (integer)
17
Adding new triple Subjecthttp://www.mydomain.com/person#john_doe Predicatehttp://www.mydomain.com/vocab#has_birthyear Object“1970”^^http://www.w3.org/2001/XMLSchema#int eger Note: “^^” is optional for specifying data type of a literal. If not specified, the default data type is string. 17
18
RDF Graph http://www.mydomain.com/person#john_doe http://www.mydomain.com/person#jack_doe http://www.mydomain.com/vocab#father-of “John Doe”@en “1970”^^http://www. w3.org/2001/XMLS chema#integer http://www.mydomain.com/vocab#has_name http://www.mydomain.com/vocab#has_birthyear 18
19
RDF/XML <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> John Doe 1970 19
20
N-Triples. "John Doe" @en. "1970"^^http://www.w3.org/2001/XMLSchema#integer. 20
21
Turtle @prefix x:. @prefix person:. @prefix xsd:. person:john_doe x:father-of person:jack_doe ; x:has_name "John Doe"@en ; x:has_birthyear "1970"^^xsd:integer. 21
22
Adding triple with “rdf:type” property
23
Adding new triple Subjecthttp://www.mydomain.com/person#jack_doe Predicatehttp://www.w3.org/1999/02/22-rdf-syntax- ns#type Objecthttp://www.mydomain.com/vocab#student 23
24
RDF Graph http://www.mydomain.com/person#john_doe http://www.mydomain.com/person#jack_doe http://www.mydomain.com/vocab#father-of “John Doe”@en “1970”^^http://www. w3.org/2001/XMLS chema#integer http://www.mydomain.com/vocab#has_name http://www.mydomain.com/vocab#has_birthyear http://www.mydomain.com/vocab#student http://www.w3.org/1999/02/22-rdf-syntax-ns#type 24
25
RDF/XML <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> John Doe 1970 25
26
N-Triples. "John Doe"@en. "1970"^^http://www.w3.org/2001/XMLSchema#integer.. 26
27
Turtle @prefix x:. @prefix person:. @prefix xsd:. person:john_doe x:father-of person:jack_doe ; x:has_name "John Doe"@en ; x:has_birthyear "1970"^^xsd:integer. person:jack_doe a x:student. 27
28
Adding triple for the same property with different values
29
Adding new triple Subjecthttp://www.mydomain.com/person#john_doe Predicatehttp://www.mydomain.com/vocab#has_name Object “ จอห์น โด ”@th Note: “@” is optional for specifying language code of a string. 29
30
RDF Graph http://www.mydomain.com/person#john_doe http://www.mydomain.com/person#jack_doe http://www.mydomain.com/vocab#father-of “John Doe”@en “1970”^^http://www. w3.org/2001/XMLS chema#integer http://www.mydomain.com/vocab#has_name http://www.mydomain.com/vocab#has_birthyear http://www.mydomain.com/vocab#student http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.mydomain.com/vocab#has_name “ จอห์น โด ”@th 30
31
RDF/XML <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> John Doe 1970 จอห์น โด 31
32
N-Triples. "John Doe"@en. "1970"^^http://www.w3.org/2001/XMLSchema#integer.. “ จอห์น โด "@th. 32
33
Turtle @prefix x:. @prefix person:. @prefix xsd:. person:john_doe x:father-of person:jack_doe ; x:has_name "John Doe"@en, “ จอห์น โด "@th ; x:has_birthyear "1970"^^xsd:integer. person:jack_doe a x:student. 33
34
Different syntaxes for “rdf:about”, “rdf:ID”, “rdf:type”
35
The following RDF.. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> Joe Clark 35
36
is equivalent to <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#" xml:base="http://www.mydomain.com/person"> Joe Clark 36
37
is equivalent to (2) <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#"> Joe Clark 37
38
is equivalent to (3) <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.mydomain.com/vocab#" xml:base="http://www.mydomain.com/person"> Joe Clark 38
39
Summary RDF triples can be represented in multiple syntaxes RDF/XML is a current standard although it is more complex than other syntaxes. Turtle is an extension of N-Tripples syntax and is a subset of Notation 3 (N3) syntax. Turtle gains more popularity due to its simplicity and has just become a standard. Turtle syntax is compatible with SPARQL syntax which makes it easier to use with SPARQL. 39
40
Lab 1. Please create the example RDF/XML data in a file “person.rdf” 1.1 Validate the created RDF data in W3C RDF Validation Service - http://www.w3.org/RDF/Validator/http://www.w3.org/RDF/Validator/ 1.2 Show the results in RDF triples and graph 2. Create the above RDF data in using N-Triples and Turtle syntax and validate the data using http://rdf.greggkellogg.net/distiller http://rdf.greggkellogg.net/distiller 40
41
Exercise 1: Add the following information to the above RDF data Full name of ‘person:jack_doe’ as “Jack Doe” (in English) and “ แจ็ค โด ” (in Thai) Add 2 phone numbers of ‘person:jack_doe’ as “082-111- 5555” and “02-123-1111” using property ‘x:has_phone’ Add birthdate of ‘person:jack_doe’ as “1970-11-11” using property ‘x:has_birthdate’ with ‘xsd:date’ datatype. Add a triple that ‘person:john_doe’ has property ‘rdf:type’ of ‘x:doctor’. 41
42
Exercise 1: Show the new RDF data in the following formats: 1) RDF Graph 2) RDF/XML 3) N-Triples 4) Turtle 42
43
Exercise: 2 <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.mydomain.com/vocab#"> Show this RDF data that makes use of RDF schema vocabulary in RDF Graph form 43
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.