RDF Syntax and examples ดร. มารุต บูรณรัช : หัวข้อพิเศษด้านเทคโนโลยีสารสนเทศขั้นสูง - เทคโนโลยีเว็บเชิงความหมาย (Special Topics in Advanced Information Technology – Semantic Web Technology) ภาควิชาวิทยาการคอมพิวเตอร์และเทคโนโลยีสารสนเทศ คณะวิทยาศาสตร์ มหาวิทยาลัยนเรศวร ภาคการศึกษาที่ 2 ปีการศึกษา 2557
RDF Syntax RDF Graph RDF/XML N-Triples Turtle (Terse RDF Triple Language) 2
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
Adding triple with object as a resource
Example RDF Triple “John Doe is a father of Jack Doe” Subjecthttp:// Predicatehttp:// Objecthttp:// 5
RDF Graph
RDF/XML <rdf:RDF xmlns:rdf=" xmlns:x=" 7
N-Triples. 8
person:. person:john_doe x:father-of person:jack_doe. 9
Adding triple with object as literal (string)
Adding new triple Subjecthttp:// Predicatehttp:// Object“John Note: is optional for specifying language code of a string. 11
RDF Graph “John 12
RDF/XML <rdf:RDF xmlns:rdf=" xmlns:x=" John Doe 13
N-Triples. "John 14
person:. person:john_doe x:father-of person:jack_doe ; x:has_name "John 15
Adding triple with object as literal (integer)
Adding new triple Subjecthttp:// Predicatehttp:// Object“1970”^^ eger Note: “^^” is optional for specifying data type of a literal. If not specified, the default data type is string. 17
RDF Graph “John “1970”^^ w3.org/2001/XMLS chema#integer
RDF/XML <rdf:RDF xmlns:rdf=" xmlns:x=" John Doe
N-Triples. "John "1970"^^ 20
xsd:. person:john_doe x:father-of person:jack_doe ; x:has_name "John ; x:has_birthyear "1970"^^xsd:integer. 21
Adding triple with “rdf:type” property
Adding new triple Subjecthttp:// Predicatehttp:// ns#type Objecthttp:// 23
RDF Graph “John “1970”^^ w3.org/2001/XMLS chema#integer
RDF/XML <rdf:RDF xmlns:rdf=" xmlns:x=" John Doe
N-Triples. "John "1970"^^ 26
xsd:. person:john_doe x:father-of person:jack_doe ; x:has_name "John ; x:has_birthyear "1970"^^xsd:integer. person:jack_doe a x:student. 27
Adding triple for the same property with different values
Adding new triple Subjecthttp:// Predicatehttp:// Object “ จอห์น โด Note: is optional for specifying language code of a string. 29
RDF Graph “John “1970”^^ w3.org/2001/XMLS chema#integer “ จอห์น โด 30
RDF/XML <rdf:RDF xmlns:rdf=" xmlns:x=" John Doe 1970 จอห์น โด 31
N-Triples. "John "1970"^^ “ จอห์น โด 32
xsd:. person:john_doe x:father-of person:jack_doe ; x:has_name "John “ จอห์น โด ; x:has_birthyear "1970"^^xsd:integer. person:jack_doe a x:student. 33
Different syntaxes for “rdf:about”, “rdf:ID”, “rdf:type”
The following RDF.. <rdf:RDF xmlns:rdf=" xmlns:x=" Joe Clark 35
is equivalent to <rdf:RDF xmlns:rdf=" xmlns:x=" xml:base=" Joe Clark 36
is equivalent to (2) <rdf:RDF xmlns:rdf=" xmlns:x=" Joe Clark 37
is equivalent to (3) <rdf:RDF xmlns:rdf=" xmlns:x=" xml:base=" Joe Clark 38
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
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 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
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 “ ” and “ ” using property ‘x:has_phone’ Add birthdate of ‘person:jack_doe’ as “ ” using property ‘x:has_birthdate’ with ‘xsd:date’ datatype. Add a triple that ‘person:john_doe’ has property ‘rdf:type’ of ‘x:doctor’. 41
Exercise 1: Show the new RDF data in the following formats: 1) RDF Graph 2) RDF/XML 3) N-Triples 4) Turtle 42
Exercise: 2 <rdf:RDF xmlns:rdf=" xmlns:rdfs=" xml:base=" Show this RDF data that makes use of RDF schema vocabulary in RDF Graph form 43