RDF and its serializations, RDFS
Jakub Klímek
This work is licensed under a Creative Commons Attribution 4.0 International License.
The principles of Linked Data
2
HTTP(S) IRIs for things and linking
3
http://praha.eu/contract/7302
http://praha.eu/city
http://mfcr.cz/
prague/budget
http://mfcr.cz/
prague
http://risy.cz/
location/prague
http://risy.cz/contract/22189-01
http://risy.cz/
project/22189
http://registry.
czso.cz/prague
http://czso.cz/
prague
http://czso.cz/prague/demogstat
c: hasBeneficiary
a:fundedBy
b:hasBudget
http://praha.eu/council
d:hasDemography
URI, URL, IRI, URN
4
URI, URL, IRI, URN
URI - Uniform Resource Identifier - RFC 3986�URN - Uniform Resource Name - RFC 8141, IANA URN namespace registry�URL - Uniform Resource Locator - RFC 3986�IRI - Internationalized Resource Identifier - RFC 3987�� foo://example.com:8042/over/there?name=ferret#nose� \_/ \______________/\_________/ \_________/ \__/� | | | | |� scheme authority path query fragment� | _____________________|__� / \ / \� urn:example:animal:ferret:nose
5
RFC 3986 - Uniform Resource Identifier - examples
6
RFC 3987 - IRI - Internationalized Resource Identifier
Examples
Percent-encoding
The same examples of IRIs percent-encoded into URIs
7
RFC 3492 - Punycode
IRIs not to be confused with IDN - internationalized domain name:
8
RDF - Resource Description Framework - idea
RDF - graph based data model - a set of triples
Triple describes a relation as:
subject predicate object
2004 & 2014 W3C Recommendations
Triples are written in one of RDF notations / syntaxes / serializations:
RDF/XML, RDFa, N-Triples, Turtle, JSON-LD, N-Quads, TriG
9
Jakub Klímek studied at Charles University .
predicate
object
subject
Jakub Klímek Charles University
studied at
RDF model: a triple, a statement
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8574> .
10
http://example.com/index.html
http://example.com/staff/8574
http://purl.org/dc/terms/creator
subject (S)
predicate (P)�(property)
object (O)
Resource / Thing
Resource / Thing
RDF model: a triple with literal value
<http://example.com/index.html> <http://purl.org/dc/terms/subject> "education" .
11
http://example.com/index.html
education
http://purl.org/dc/terms/subject
subject (S)
predicate (P)
object (O)
Resource
Literal
RDF serializations: IRIs and IRI prefixes
<http://purl.org/dc/terms/creator>
=
@prefix dcterms: <http://purl.org/dc/terms/> .
dcterms:creator
12
RDF model: multiple properties
my:index.html dcterms:creator exstaff:85740 .�my:index.html dcterms:subject "education" .�my:index.html dcterms:language "en" .
13
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
a set�i.e. no ordering among triples
RDF model: typed literals
my:index.html dcterms:created "2020-04-23"^^xsd:date .
14
my:index.html
"2020-04-23"^^<http://www.w3.org/2001/XMLSchema#date>
dcterms:created
RDF model: text literals with a language tag
my:index.html dcterms:title "Homepage of Jakub Klímek"@en .
15
my:index.html
"Homepage of Jakub Klímek"@en
dcterms:title
RDF model: classes
16
my:Person
my:staff/85740
rdf:type
Resource
Resource
Class
RDF model: blank nodes
my:staff/85740 my:hasAddress _:a1 .
_:a1 my:street "Malostranske nam. 25" .�_:a1 my:city "Prague" .�_:a1 my:zipCode "11800" .
17
my:street
Prague
11800
my:zipCode
my:city
my:staff/85740
my:hasAddress
Malostranské nám. 25
RDF model: rdf:List for closed collection
18
rdf:List
my:item1
my:item2
rdf:type
rdf:first
rdf:rest
my:list
rdf:nil
rdf:first
rdf:rest
rdf:type
rdf:type
RDF model: containers for open collections
rdf:Bag, rdf:Seq, rdf:Alt
19
my:bag
my:item1
my:item2
my:item3
rdf:Bag
rdf:type
rdf:_1
rdf:_2
rdf:_3
RDF - Resource Description Framework
20
RDF serializations
21
RDF 1.1 N-Triples
22
<http://one.example/subject1> <http://one.example/predicate1> <http://one.example/object1> . # comments here
<http://example.org/show/218> <http://example.org/show/localName> "That Seventies Show"@en . # literal with a language tag
�<http://en.wikipedia.org/wiki/Helium> <http://example.org/elements/atomicNumber> "2"^^<http://www.w3.org/2001/XMLSchema#integer> . # xsd:integer
RDF 1.1 N-Triples
<http://example.com/index.html> <http://purl.org/dc/terms/created> "2020-04-23"^^<http://…#date> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8574> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8575> .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "Moje stránka"@cs .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "My page"@en .
23
RDF 1.1 Turtle - Prefixes
<http://example.com/index.html> <http://purl.org/dc/terms/created> "2020-04-23"^^<http://…#date> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8574> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8575> .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "Moje stránka"@cs .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "My page"@en .
24
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .�@prefix dcterms: <http://purl.org/dc/terms/> .�@prefix my: <http://example.com/> .�@prefix staff: <http://example.com/staff/> .��my:index.html dcterms:created "2020-04-23"^^xsd:date .
my:index.html dcterms:creator staff:8574 .
my:index.html dcterms:creator staff:8575 .
my:index.html dcterms:title "Moje stránka"@cs .
my:index.html dcterms:title "My page"@en .
RDF 1.1 Turtle - Prefixes and ";"
<http://example.com/index.html> <http://purl.org/dc/terms/created> "2020-04-23"^^<http://…#date> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8574> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8575> .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "Moje stránka"@cs .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "My page"@en .
25
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .�@prefix dcterms: <http://purl.org/dc/terms/> .�@prefix my: <http://example.com/> .�@prefix staff: <http://example.com/staff/> .��my:index.html dcterms:created "2020-04-23"^^xsd:date ;
dcterms:creator staff:8574 ;
dcterms:creator staff:8575 ;
dcterms:title "Moje stránka"@cs ;
dcterms:title "My page"@en .
RDF 1.1 Turtle - Prefixes and ";" and ","
<http://example.com/index.html> <http://purl.org/dc/terms/created> "2020-04-23"^^<http://…#date> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8574> .
<http://example.com/index.html> <http://purl.org/dc/terms/creator> <http://example.com/staff/8575> .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "Moje stránka"@cs .
<http://example.com/index.html> <http://purl.org/dc/terms/title> "My page"@en .
26
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .�@prefix dcterms: <http://purl.org/dc/terms/> .�@prefix my: <http://example.com/> .�@prefix staff: <http://example.com/staff/> .��my:index.html dcterms:created "2020-04-23"^^xsd:date ;
dcterms:creator staff:8574 ,
staff:8575 ;
dcterms:title "Moje stránka"@cs ,
"My page"@en .
RDF 1.1 Turtle - More prefixes
@prefix foo: <http://example.org/ns#> .�@prefix : <http://other.example.org/ns#> .
foo:bar foo: : .�:bar : foo:bar .
<http://example.org/ns#bar> <http://example.org/ns#> <http://other.example.org/ns#> .
<http://other.example.org/ns#bar> <http://other.example.org/ns#> <http://example.org/ns#bar> .
27
RDF 1.1 Turtle - Relative IRIs
Need to know, relative to WHAT the IRI is.
Assuming Document URL https://test.org/doc��@prefix foo: <http://example.org/ns#> .��<#document> foo: <https://jk.com> .��@base <http://newbase.com/> .�<#document> foo: <https://jk.com> .
<https://test.org/doc#document> <http://example.org/ns#> <https://jk.com> .
<http://newbase.com/#document> <http://example.org/ns#> <https://jk.com> .
28
RDF 1.1 Turtle - Multiline strings, escapes
"""a string�with newlines�"""
29
RDF 1.1 Turtle - Class assignment (rdf:type)
�<http://example.com/index.html> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> foaf:Document .
=
<http://example.com/index.html> a foaf:Document .
30
RDF 1.1 Turtle - blank nodes
<http://example.com/> a v:VCard ;� v:adr [
a v:Work ;
v:country-name "Australia" ;
v:locality "WonderCity" ;
v:postal-code "5555" ;
v:street-address "33 Enterprise Drive"
] ;
.
<http://example.com/> v:adr _:1234 .
_:1234 a v:Work ;
v:locality "WonderCity" ;
...
31
=
RDF 1.1 Turtle - datatype shortcuts
ex:Car ex:numberOfWheels 4 ;
ex:Car ex:numberOfWheels +4 ;
ex:Car ex:numberOfWheels "4"^^xsd:integer ;
ex:Car ex:value 1300000.0 ;
ex:Car ex:value "1300000.0"^^xsd:decimal ;
ex:Car ex:value 1.3e6 ;
ex:Car ex:value "1.3e6"^^xsd:double ;
ex:Car ex:leftHandDrive true ;
ex:Car ex:leftHandDrive "true"^^xsd:boolean ;
32
RDF 1.1 Turtle - rdf:List shortcut
# the value of this triple is the RDF collection blank node
:subject :predicate ( :a :b :c ) .
# an empty collection value - rdf:nil
:subject :predicate2 () .
33
RDF 1.1 Turtle - playing with prefixes and rel. IRIs
# In-scope base IRI is the document URI at this point�<a1> <b1> <c1> .�@base <http://example.org/ns/> .��# In-scope base IRI is http://example.org/ns/ at this point�<a2> <http://example.org/ns/b2> <c2> .�@base <foo/> .��# In-scope base IRI is http://example.org/ns/foo/ at this point�<a3> <b3> <c3> .�@prefix : <bar#> .�:a4 :b4 :c4 .�@prefix : <http://example.org/ns2#> .�:a5 :b5 :c5 .
34
http://example.org/ns/c2
http://example.org/ns/foo/
http://example.org/ns/foo/c3
http://example.org/ns/foo/bar#
http://example.org/ns/foo/bar#c4
http://example.org/ns2#c5
Detour from RDF serializations
35
RDF model - statements about statements
my:index.html my:createdBy "Jakub Klímek" .
36
This statement
How to represent these facts in RDF?
RDF model - reification
Direct approach to the problem:
Statement will become a resource.
Original statement:
my:index.html my:createdBy "Jakub Klímek" .
Reified statement:
_:triple1 a rdf:Statement .
_:triple1 rdf:subject my:index.html .
_:triple1 rdf:predicate my:createdBy .
_:triple1 rdf:object "Jakub Klímek" .
37
Possibility of additional statements we need:
_:triple1 dcterms:created "2020-04-23"^^xsd:date .
RDF model - named graphs
Alternative approach to the problem:
RDF Triples become RDF Quads
38
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
https://example.org/named-graphs/1
RDF dataset
Consists of
39
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
my:index.html
my:staff/85740
dcterms:creator
education
en
dcterms:language
dcterms:subject
https://example.org/named-graphs/1
https://example.org/named-graphs/2
default graph
Back to RDF serializations
40
RDF 1.1 N-Quads
S P O G
<http://example.org/#spiderman> <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#green-goblin> <http://example.org/graphs/spiderman> .
41
RDF 1.1 TriG
RDF Dataset consists of
@base <http://www.w3.org/People/> .
@prefix : <http://xmlns.com/foaf/0.1/> .
# default graph
{
ericFoaf:ericP :givenName "Eric" .
}
# also default graph, no {}
ericFoaf:ericP :givenName "Eric" .
# graph highlight
GRAPH <Eric/ericP-foaf.rdf> {
ericFoaf:ericP :givenName "Eric" .
}
42
RDFS: RDF Schema
43
RDFS - RDF Schema 1.1
Vocabulary for creation of other RDF vocabularies
44
RDFS - defining classes and class hierarchies
ex:MotorVehicle rdf:type rdfs:Class .
ex:PassengerVehicle rdf:type rdfs:Class .
ex:Van rdf:type rdfs:Class .
ex:Truck rdf:type rdfs:Class .
ex:MiniVan rdf:type rdfs:Class .
ex:PassengerVehicle rdfs:subClassOf ex:MotorVehicle .
ex:Van rdfs:subClassOf ex:MotorVehicle .
ex:Truck rdfs:subClassOf ex:MotorVehicle .
ex:MiniVan rdfs:subClassOf ex:Van .
ex:MiniVan rdfs:subClassOf ex:PassengerVehicle .
45
RDFS - defining classes and class hierarchies
46
ex:MotorVehicle
ex:Truck
ex:Van
ex:PassengerVehicle
ex:MiniVan
rdfs:subclassOf
rdfs:subclassOf
rdfs:subclassOf
rdfs:subclassOf
rdfs:subclassOf
RDFS - defining properties and property hierarchies
ex:Person rdf:type rdfs:Class .
ex:author rdf:type rdf:Property .
ex:author rdfs:range ex:Person .
ex:hasMother rdf:type rdf:Property .
ex:hasMother rdfs:range ex:Female .
ex:hasMother rdfs:domain ex:Person .
ex:age rdf:type rdf:Property .
ex:age rdfs:range xsd:integer .
exterms:weight rdfs:domain ex:Book .
exterms:weight rdfs:domain ex:MotorVehicle .
ex:driver rdf:type rdf:Property .
ex:primaryDriver rdf:type rdf:Property .
ex:primaryDriver rdfs:subPropertyOf ex:driver .
47
RDFS - property hierarchies
48
ex:Person
ex:MotorVehicle
ex:driver
ex:primaryDriver
ex:driver a rdf:Property .
ex:primaryDriver a rdf:Property .
ex:primaryDriver rdfs:subPropertyOf
ex:driver .
RDFS: label, comment, seeAlso
49
Example of vocabulary defined by RDFS
#Vocabulary, represented using RDF and the RDFS vocabulary
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <https://example.org/> .
ex:MotorVehicle a rdfs:Class ;
rdfs:label "Motor vehicle"@en, "Motorové vozidlo"@cs ;
rdfs:comment "Vehicle, which has a motor"@en,
"Vozdilo, které má motor"@cs .
ex:PassengerVehicle a rdfs:Class ;
rdfs:label "Passenger vehicle"@en, "Vozidlo pro cestující"@cs ;
rdfs:subClassOf ex:MotorVehicle .
ex:driver a rdf:Property ;
rdfs:label "Driver"@en, "Řidič"@cs ;
rdfs:domain ex:MotorVehicle ;
rdfs:range foaf:Person .
ex:primaryDriver a rdf:Property .
rdfs:label "Primary driver"@en, "Hlavní řidič"@cs ;
rdfs:subPropertyOf ex:driver .
#Instances, data, also represented using RDF
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ex: <https://example.org/> .
@prefix exr: <https://example.org/resource/> .
exr:1 a ex:PassengerVehicle ;
dcterms:title "Moje první auto"@cs, "My first car"@en ;
ex:primaryDriver <https://jakub.klímek.com/#me> .
exr:2 a ex:PassengerVehicle ;
dcterms:title "Moje druhé auto"@cs, "My second car"@en ;
ex:primaryDriver <https://jakub.klímek.com/#me> .
50
# Inferred triples (a.k.a. reasoning)
exr:1 a ex:MotorVehicle .
exr:2 a ex:MotorVehicle .
<https://jakub.klímek.com/#me> a foaf:Person .
exr:1 ex:driver <https://jakub.klímek.com/#me> .
exr:2 ex:driver <https://jakub.klímek.com/#me> .
Back to RDF serializations
51
JSON-LD 1.1 - JSON for Linked Data
"@context":
{
"name": "http://schema.org/name",
"image": {
"@id": "http://schema.org/image",
"@type": "@id"
},
"homepage": {
"@id": "http://schema.org/url",
"@type": "@id"
}
},
52
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"�}
JSON-LD @context��Makes JSON interpretable as RDF model through mapping specified by @keywords
Normal JSON
{
JSON-LD 1.1 - JSON for Linked Data
53
JSON-LD - subject identifier (IRI)
{
"@context":
{
...
"name": "http://schema.org/name"
},
"@id": "http://me.markus-lanthaler.com/",
"name": "Markus Lanthaler",
...
}
54
http://me.markus-lanthaler.com/
"Markus Lanthaler"
http://schema.org/name
JSON-LD - type/class identifier (IRI)
{
...
"@id": "http://example.org/places#BrewEats",
"@type": "http://schema.org/Restaurant",
...
}��{
...
"@id": "http://example.org/places#BrewEats",
"@type": [ "http://schema.org/Restaurant", "http://schema.org/Brewery" ],
...
}
{
"@context": {
...
"Restaurant": "http://schema.org/Restaurant",
"Brewery": "http://schema.org/Brewery"
},
"@id": "http://example.org/places#BrewEats",
"@type": [ "Restaurant", "Brewery" ],
...
}
55
http://example.org/places#BrewEats
s:Brewery
s:Restaurant
rdf:type
rdf:type
JSON-LD - base IRI
{
"@context": {
"@base": "http://example.com/document.jsonld"
},
"@id": "",
"label": "Just a simple document"
}
56
= http://example.com/document.jsonld�(relative to @base)
JSON-LD - default vocabulary
{
"@context": {
"@vocab": "http://schema.org/"
},
"@id": "http://example.org/places#BrewEats",
"@type": "Restaurant",
"name": "Brew Eats"
...
}
57
http://example.org/places#BrewEats
s:Restaurant
rdf:type
Brew Eats
schema:name
JSON-LD - exempting keys from RDF
{
"@context":
{
"@vocab": "http://schema.org/",
"databaseId": null
},
"@id": "http://example.org/places#BrewEats",
"@type": "Restaurant",
"name": "Brew Eats",
"databaseId": "23987520"
}
58
http://example.org/places#BrewEats
Brew Eats
s:Restaurant
schema:name
rdf:type
JSON-LD - compact IRIs
{
"@context":
{
"foaf": "http://xmlns.com/foaf/0.1/"
...
},
"@type": "foaf:Person"
"foaf:name": "Dave Longley",
...
}
59
"Dave Longley"
foaf:Person
foaf:name
rdf:type
JSON-LD - value type in context
{
"@context":
{
"modified":
{
"@id": "http://purl.org/dc/terms/modified",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
}
},
...
"@id": "http://example.com/docs/1",
"modified": "2010-05-29T14:17:39+02:00",
...
}
60
http://example.com/docs/1
"2010-05-29T14:17:39+02:00"^^xsd:dateTime
http://purl.org/dc/terms/modified
JSON-LD - embedding
{
...
"name": "Manu Sporny",
"knows":
{
"@type": "Person",
"name": "Gregg Kellogg",
}
...
}
61
Manu Sporny
foaf:name
foaf:knows
foaf:Person
Gregg Kellogg
rdf:type
foaf:name
JSON-LD - scoped contexts
{
"@context":
{
"name": "http://example.com/person#name,
"details": "http://example.com/person#details"
}",
"name": "Markus Lanthaler",
...
"details":
{
"@context":
{
"name": "http://example.com/organization#name"
},
"name": "Graz University of Technology"
}
}
62
Markus Lanthaler
http://example.com/person#name
http://example.com/person#details
Graz University of Technology
http://example.com/organization#name
JSON-LD - languages
{
"@context": {
...
"ex": "http://example.com/vocab/",
"@language": "ja",
"name": { "@id": "ex:name", "@language": null },
"occupation": { "@id": "ex:occupation" },
"occupation_en": { "@id": "ex:occupation", "@language": "en" },
"occupation_cs": { "@id": "ex:occupation", "@language": "cs" }
},
"name": "Yagyū Muneyoshi",
"occupation": "忍者",
"occupation_en": "Ninja",
"occupation_cs": "Nindža",
...
}
63
"Ninja"@en
"忍者"@ja
ex:occupation
ex:occupation
"Yagyū Muneyoshi"
"Nindža"@cs
ex:name
ex:occupation
JSON-LD - language maps
{
"@context":
{
...
"occupation": { "@id": "ex:occupation", "@container": "@language" }
},
"name": "Yagyū Muneyoshi",
"occupation":
{
"ja": "忍者",
"en": "Ninja",
"cs": "Nindža"
}
...
}
64
"Ninja"@en
"忍者"@ja
ex:occupation
ex:occupation
"Yagyū Muneyoshi"
"Nindža"@cs
ex:name
ex:occupation
JSON-LD - multiple values
{
...
"@id": "http://example.org/people#joebob",
"nick": [ "joe", "bob", "JB" ],
...
}
{
...
"@id": "http://example.org/people#joebob",
"foaf:nick":
{
"@list": [ "joe", "bob", "jaybee" ]
},
...
}
65
JSON-LD - reverse properties 0/2
[
{
"@id": "#homer",
"http://example.com/vocab#name": "Homer"
},
{
"@id": "#bart",
"http://example.com/vocab#name": "Bart",
"http://example.com/vocab#parent": { "@id": "#homer" }
},
{
"@id": "#lisa",
"http://example.com/vocab#name": "Lisa",
"http://example.com/vocab#parent": { "@id": "#homer" }
}
]
66
JSON-LD - reverse properties 1/2
{
"@id": "#homer",
"http://example.com/vocab#name": "Homer",
"@reverse": {
"http://example.com/vocab#parent": [
{
"@id": "#bart",
"http://example.com/vocab#name": "Bart"
},
{
"@id": "#lisa",
"http://example.com/vocab#name": "Lisa"
}
]
}
}
67
JSON-LD - reverse properties 2/2
{
"@context": {
"name": "http://example.com/vocab#name",
"children": { "@reverse": "http://example.com/vocab#parent" }
},
"@id": "#homer",
"name": "Homer",
"children": [
{
"@id": "#bart",
"name": "Bart"
},
{
"@id": "#lisa",
"name": "Lisa"
}
]
}
68
#homer
#lisa
http://example.com/vocab#parent
#bart
JSON-LD - named graphs
{
"@context": {
"generatedAt": {
"@id": "http://www.w3.org/ns/prov#generatedAtTime",
"@type": "http://www.w3.org/2001/XMLSchema#date"
},
"Person": "http://xmlns.com/foaf/0.1/Person",
"name": "http://xmlns.com/foaf/0.1/name",
"knows": "http://xmlns.com/foaf/0.1/knows"
},
"@id": "http://example.org/graphs/73",
"generatedAt": "2012-04-09",
"@graph":
[
{
"@id": "http://manu.sporny.org/about#manu",
"@type": "Person",
"name": "Manu Sporny",
"knows": "http://greggkellogg.net/foaf#me"
}
]
}
69
JSON-LD - aliasing keywords
{
"@context":
{
"url": "@id",
"type": "@type",
"Person": "http://xmlns.com/foaf/0.1/Person",
"name": "http://xmlns.com/foaf/0.1/name"
},
"url": "http://example.com/about#gregg",
"type": "Person",
"name": "Gregg Kellogg"
}
70
JSON-LD - adding external context to JSON
{
"@context": "https://example.org/context.jsonld",
"url": "http://example.com/about#gregg",
"type": "Person",
"name": "Gregg Kellogg"
}
71
JSON-LD - adding external context to JSON
GET /ordinary-json-document.json HTTP/1.1
Host: example.com
Accept: application/ld+json,application/json,*/*;q=0.1
====================================
HTTP/1.1 200 OK
...
Content-Type: application/json
Link: <http://json-ld.org/contexts/person.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"
{
"name": "Markus Lanthaler",
"homepage": "http://www.markus-lanthaler.com/",
"image": "http://twitter.com/account/profile_image/markuslanthaler"
}
72
RDF 1.1 XML Syntax (RDF/XML)
The oldest RDF serialization
73
RDF/XML - basic RDF triple
<rdf:RDF …>
<rdf:Description rdf:about="SubjectResource">
<PredicateResource>ObjectLiteral</PredicateResource>
<PredicateResource rdf:resource="ObjectResource"/>
…
</rdf:Description>
…
</rdf:RDF>
74
RDF/XML - blank nodes
<rdf:RDF …>
<rdf:Description rdf:about="SubjectResource">
<PredicateResource rdf:nodeID="BlankNode"/>
</rdf:Description>
<rdf:Description rdf:nodeID="BlankNode">
…
</rdf:Description>
…
</rdf:RDF>
75
RDF/XML - typed literals
Typed literals
<rdf:Description rdf:about="SubjectResource">
<PredicateResource rdf:datatype="LiteralType">
ObjectLiteral
</PredicateResource>
</rdf:Description>
<!-- Alternatively using XML entities -->
<!DOCTYPE rdf:RDF [<!ENTITY my "TypePrefix">]>
…
<… rdf:datatype="&my;TypeName">…</…>
76
RDF/XML - XML literals
In graph, this literal has datatype rdf:XMLLiteral
<?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/"
xml:base="http://www.example.com/books">
<rdf:Description rdf:ID="book12345">
<dc:title rdf:parseType="Literal">
<span xml:lang="en">
The <em><br /></em> Element Considered Harmful.
</span>
</dc:title>
</rdf:Description>
</rdf:RDF>
77