<http://somewhere/JohnSmith/>
http://www.w3.org/2001/vcard-rdf/3.0#FN "John Smith" .
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
<http://somewhere/JohnSmith/> vcard:FN "John Smith" .
Graphical representation :
<rdf:Description>
rdf:about
) <rdf:Description>
rdf:resource
)
of the relator element<rdf:RDF
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'>
<rdf:Description
rdf:about='http://somewhere/JohnSmith/'>
<vcard:FN>John
Smith</vcard:FN>
</rdf:Description>
<rdf:RDF>
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://somewhere/JohnSmith/>
vcard:FN "John Smith" ;
foaf:knows
<http://somewhere/RebeccaSmith/> .
<http://somewhere/RebeccaSmith/>
vcard:FN "Becky Smith" .
vcfoaf.rdf
) : <?xml version="1.0"?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'
xmlns:foaf='http://xmlns.com/foaf/0.1/' >
<rdf:Description rdf:about='http://somewhere/JohnSmith/'>
<vcard:FN>John Smith</vcard:FN>
</rdf:Description>
<rdf:Description rdf:about='http://somewhere/JohnSmith/'>
<foaf:knows
rdf:resource='http://somewhere/RebeccaSmith/'/>
</rdf:Description>
<rdf:Description
rdf:about='http://somewhere/RebeccaSmith/'>
<vcard:FN>Becky Smith</vcard:FN>
</rdf:Description>
</rdf:RDF>
vcard
system, in addition to the
full name vcard:FN
which has a
constant string as its object,vcard:N
which is
only determined by two relations, each of which has an ordinary string
as its object :vcard:Given
for the first name,
or Christian name, French prénom, German Vorname,
Italian nome...vcard:Family
for the family name,
French nom, German Name, Italian cognome...<http://somewhere/JohnSmith/>
vcard:FN "John Smith" ;
vcard:N [ vcard:Family "Smith" ;
vcard:Given "John"
] .
rdf:nodeID
instead of rdf:about
and of rdf:resource
<rdf:Description
rdf:about='http://somewhere/JohnSmith/'>
<vcard:FN>John Smith</vcard:FN>
<vcard:N rdf:nodeID="A0"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A0">
<vcard:Family>Smith</vcard:Family>
<vcard:Given>John</vcard:Given>
</rdf:Description>
vcardCat.rdf
(XML) and vcardCat.n3
(N3 notation).vCard
for the usual contents of a business
card, foaf
(Friend Of a Friend) for social relationsdshipsdc
(Dublin Core Metadata) for metadata relating to authorship of published
documents etc.rdf:resource
of relator dc:creator
.xml:base
feature with
rdf:ID
attributes of examples 11 to 13.http://somewhere/
").xml:base
URI, #
'.base#fragment.
vcfoaf2.rdf
.)<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'
xmlns:foaf='http://xmlns.com/foaf/0.1/'
xmlns:dc='http://purl.org/dc/elements/1.1/'
xmlns:exterms="http://www.example.org/terms/"
xml:base = 'http://somewhere/'
>
<rdf:Description
rdf:about="http://www.example.org/index.html">
<exterms:creation-date rdf:datatype=
"http://www.w3.org/2001/XMLSchema#date">1999-08-16
</exterms:creation-date>
<dc:creator rdf:resource="#JohnSmith/"/>
</rdf:Description>
<rdf:Description rdf:about='#JohnSmith/'>
<vcard:FN>John Smith</vcard:FN>
<vcard:N rdf:nodeID="A0"/>
<foaf:knows rdf:resource='#RebeccaSmith/'/>
</rdf:Description>
<rdf:Description rdf:about='#RebeccaSmith/'>
<foaf:knows rdf:resource='#JohnSmith/'/>
<vcard:FN>Becky Smith</vcard:FN>
<vcard:N rdf:nodeID="A3"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A0">
<vcard:Family>Smith</vcard:Family>
<vcard:Given>John</vcard:Given>
</rdf:Description>
<rdf:Description rdf:nodeID="A3">
<vcard:Family>Smith</vcard:Family>
<vcard:Given>Rebecca</vcard:Given>
</rdf:Description>
</rdf:RDF>
@prefix exterms:
<http://www.example.org/terms/> .
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix dc:
<http://purl.org/dc/elements/1.1/> .
@prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://www.example.org/index.html>
dc:creator
<http://somewhere/#JohnSmith/> ;
exterms:creation-date
"""1999-08-16
"""^^<http://www.w3.org/2001/XMLSchema#date> .
<http://somewhere/#JohnSmith/>
vcard:FN "John Smith" ;
vcard:N [ vcard:Family "Smith" ;
vcard:Given "John"
] ;
foaf:knows
<http://somewhere/#RebeccaSmith/> .
<http://somewhere/#RebeccaSmith/>
vcard:FN "Becky Smith" ;
vcard:N [ vcard:Family "Smith" ;
vcard:Given "Rebecca"
] ;
foaf:knows
<http://somewhere/#JohnSmith/> .
rNN2.xml
]<?xml version="1.0"?>
<!DOCTYPE list SYSTEM "NN2.dtd">
<list>
<student>
<name>Elisabeth</name>
<mark>07</mark>
</student>
<student>
<name>Luc</name>
<mark>12</mark>
</student>
<student>
<name>Maurice</name>
<mark>18</mark>
</student>
<student>
<name>Juliette</name>
<mark>07</mark>
</student>
</list>
rNN2.rdf
]<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:epita="http://epita/masters/international/"
xml:base="http://epita/masters/international/perso">
<rdf:Description rdf:about="#Elisabeth">
<epita:mark>07</epita:mark>
</rdf:Description>
<rdf:Description rdf:about="#Luc">
<epita:mark>12</epita:mark>
</rdf:Description>
<rdf:Description rdf:about="#Maurice">
<epita:mark>18</epita:mark>
</rdf:Description>
<rdf:Description rdf:about="#Juliette">
<epita:mark>07</epita:mark>
</rdf:Description>
</rdf:RDF>
@prefix epita:
<http://epita/masters/international/> .
@prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://epita/masters/international/perso#
Elisabeth
>
epita:note "
07
"
.
<http://epita/masters/international/perso#
Luc
>
epita:note "
12
"
.
<http://epita/masters/international/perso#
Maurice
>
epita:note "
18
"
.
<http://epita/masters/international/perso#
Juliette
>
epita:note "
07
"
.
NN2RDFb.xsl
]<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:epita="http://epita/masters/international/"
>
<xsl:output method="xml" indent="yes" encoding="utf-8" />
<xsl:template match="/">
<rdf:RDF
xml:base="http://epita/masters/international/perso" >
<xsl:apply-templates />
</rdf:RDF>
</xsl:template>
<xsl:template match="student">
<rdf:Description rdf:about="#{name}">
<epita:mark>
<xsl:value-of select="mark" />
</epita:mark>
</rdf:Description>
</xsl:template>
</xsl:stylesheet>
{name}
' in <rdf:Description
rdf:about="#{name}">
.name
' is put between curly
brackets, inside a constant string (attribute value).<xsl:value-of
xelect="name" />
)rdf:type
rdf:type
http://example.net/Paul_Dupont
"
is a Person in the sense of the foaf
vocabulary, <rdf:Description
rdf:about="http://example.net/Paul_Dupont">
<rdf:type
rdf:resource="http://xmlns.com/foaf/0.1/Person" />
</rdf:Description>
<rdf:Description
rdf:about="http://example.net/Paul_Dupont">
<rdf:type
rdf:resource="http://xmlns.com/foaf/0.1/Person" />
<foaf:name>Paul Dupont</foaf:name>
<foaf:img
rdf:resource="http://example.net/Paul_Dupont.jpg"/>
<foaf:knows
rdf:resource="http://example.net/Pierre_Dumoulin"/>
</rdf:Description>
rdf:type
relationship is a very special
one, <foaf:Person
rdf:about="http://example.net/Paul_Dupont">
<foaf:name>Paul
Dupont</foaf:name>
<foaf:img
rdf:resource="http://example.net/Paul_Dupont.jpg"/>
<foaf:knows
rdf:resource="http://example.net/Pierre_Dumoulin"/>
</foaf:Person>
ExWiki.rdf
(which uses only the shorthand
notation) and ExWiki2.rdf
(which uses both),ExWiki.n3
),
which exhibits the special syntax for rdf:type
in N3 :<http://example.net/Paul_Dupont>
a
foaf:Person ;
......
SELECT
: yields a flat collection of results
(as with SQL)CONSTRUCT
: yields results organised
as an RDF graph$JENAROOT/bin/sparql
FROM
...)$JENAROOT/bin/sparql --query path
$JENAROOT/bin/sparql --data path --query path
--results XML
" [only for queries of SELECT
type, not for CONSTRUCT
!]FROM
field pointing to a RDF
file located on a publicly accessible server,CONSTRUCT
queries support
only text
output, which generates N3 syntax.SELECT
SELECT
query (file vcard1.rq)
PREFIX vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#>
SELECT ?prenom
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/Exemples/vcardCat.rdf>
WHERE {
?x vcard:N ?c .
?c vcard:Given ?prenom .
}
vcardCat.rdf
-------------
| prenom |
=============
| "Rebecca" |
| "Matthew" |
| "Sarah" |
| "John" |
-------------
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="prenom"/>
</head>
<results>
<result>
<binding name="prenom">
<literal>Rebecca</literal>
</binding>
</result>
<result>
<binding name="prenom">
<literal>Matthew</literal>
</binding>
</result>
<result>
<binding name="prenom">
<literal>Sarah</literal>
</binding>
</result>
<result>
<binding name="prenom">
<literal>John</literal>
</binding>
</result>
</results>
</sparql>
SELECT
query (file ExWiki.rq
)
PREFIX rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?nom ?image ?description
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/ExWiki.rdf>
WHERE {
?personne rdf:type foaf:Person .
?personne foaf:name ?nom .
?image rdf:type foaf:Image .
?personne foaf:img ?image .
?image dc:description ?description
}
ExWiki.rdf
--------------------------------------------------------------------------------------------------------
|
nom
|
image
|
description
|
========================================================================================================
| "Pierre Dumoulin" | <http://example.net/Pierre_Dumoulin.jpg> |
"Photo d'identité de Pierre Dumoulin" |
| "Paul Dupont" |
<http://example.net/Paul_Dupont.jpg> |
"Photo d'identité de Paul Dupont" |
--------------------------------------------------------------------------------------------------------
CONSTRUCT
ExConstruct1.rq)
:
people with the same family name are likely to know
each other.PREFIX foaf:
<http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?x foaf:knows ?y }
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/Exemples/vcardCat.rdf>
WHERE
{ ?x
vcard:N ?va .
?va
vcard:Family ?f .
?y
vcard:N ?vb .
?vb
vcard:Family ?f .
FILTER (?va != ?vb )
}
vcardCat.rdf
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://somewhere/RebeccaSmith/>
foaf:knows
<http://somewhere/JohnSmith/> .
<http://somewhere/JohnSmith/>
foaf:knows
<http://somewhere/RebeccaSmith/> .
<http://somewhere/SarahJones/>
foaf:knows
<http://somewhere/MattJones/> .
<http://somewhere/MattJones/>
foaf:knows
<http://somewhere/SarahJones/> .
ExConstruct1b.rq
)PREFIX foaf:
<http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?x foaf:knows ?y }
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/Exemples/vcardCat.rdf>
WHERE
{ ?x
vcard:N ?va .
?va
vcard:Family ?f .
?y
vcard:N ?vb .
?vb
vcard:Family ?f .
FILTER (?va != ?vb &&
STR(?x) < STR(?y) )
}
STR
function defines the string
representation of its argument, '<
' is the
lexicographical ordering.@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://somewhere/JohnSmith/>
foaf:knows
<http://somewhere/RebeccaSmith/> .
<http://somewhere/MattJones/>
foaf:knows
<http://somewhere/SarahJones/> .
foaf
vocabulary to vCard
(file ExConstruct2.rq
)foaf:name
<==> vcard:FN
PREFIX foaf:
<http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?x vcard:FN ?y }
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/ExWiki.rdf>
WHERE { ?x foaf:name ?y }
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example.net/Pierre_Dumoulin>
vcard:FN
"Pierre Dumoulin" .
<http://example.net/Paul_Dupont>
vcard:FN
"Paul Dupont" .
vCard
vocabulary to foaf
(file ExConstruct3.rq
)foaf:firstName
<==> vcard:N ->
vcard:Given
foaf:lastName
<==> vcard:N
-> vcard:Family
PREFIX foaf:
<http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?x foaf:firstName ?y .
?x
foaf:lastName ?z .
}
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/Exemples/vcardCat.rdf>
WHERE
{ ?x vcard:N ?u .
?u vcard:Given
?y .
?u vcard:Family
?z.
}
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://somewhere/RebeccaSmith/>
foaf:firstName "Rebecca" ;
foaf:lastName "Smith" .
<http://somewhere/JohnSmith/>
foaf:firstName "John" ;
foaf:lastName "Smith" .
<http://somewhere/SarahJones/>
foaf:firstName "Sarah" ;
foaf:lastName "Jones" .
<http://somewhere/MattJones/>
foaf:firstName "Matthew" ;
foaf:lastName "Jones" .
RRb.rdf
)
was extracted from an XML file
taken from the Frantext repository.<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:vc="http://www.w3.org/2001/vcard-rdf/3.0#"
xml:base="http://inalco/M2-Trad/poetes">
<rdf:Description rdf:about="#Odes_funambulesques">
<dc:title>Odes funambulesques</dc:title>
</rdf:Description>
<rdf:Description rdf:about="#Théodore_de_BANVILLE">
<vc:FN>Théodore de BANVILLE</vc:FN>
</rdf:Description>
<rdf:Description rdf:about="#Odes_funambulesques">
<dc:publisher>Paris : M. Levy,
1859.</dc:publisher>
</rdf:Description>
<rdf:Description rdf:about="#Odes_funambulesques">
<dc:creator
rdf:resource="#Théodore_de_BANVILLE"/>
</rdf:Description>
<rdf:Description rdf:about="#Théodore_de_BANVILLE">
<vc:N rdf:nodeID="A0"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A0">
<vc:Given>Théodore</vc:Given>
</rdf:Description>
<rdf:Description rdf:nodeID="A0">
<vc:Family>de BANVILLE</vc:Family>
</rdf:Description>
</rdf:RDF>
dc:creator
), we pick foaf:pastProject
as a substitute._:oeuvre
"ExConstruct4.rq
)PREFIX foaf:
<http://xmlns.com/foaf/0.1/>
PREFIX dc:
<http://purl.org/dc/elements/1.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?auteur foaf:pastProject _:oeuvre .
_:oeuvre dc:title ?nom .
_:oeuvre dc:publisher ?editeur .
?auteur foaf:firstName ?p .
?auteur foaf:lastName ?n .
}
FROM
<http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/Frantext/RRb.rdf>
WHERE
{ ?oe
dc:creator ?auteur .
?oe
dc:title ?nom .
?oe
dc:publisher ?editeur .
?auteur vcard:N ?vc .
?vc
vcard:Family ?n .
?vb
vcard:Given ?p .
}
@prefix dc:
<http://purl.org/dc/elements/1.1/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard:
<http://www.w3.org/2001/vcard-rdf/3.0#> .
<http://inalco/M2-Trad/poetes#Théodore_de_BANVILLE>
foaf:firstName "Théodore" ;
foaf:lastName "de BANVILLE" ;
foaf:pastProject
[ dc:publisher "Paris : M. Levy, 1859." ;
dc:title "Odes funambulesques"
] .
http://en.wikipedia.org/wiki/Name
-->
http://dbpedia.org/page/Name
http://en.wikipedia.org/wiki/Mary_Shelley
http://dbpedia.org/page/Mary_Shelley
http://dbpedia.org/data/Name.rdf
http://dbpedia.org/data/Mary_Shelley.rdf
http://dbpedia.org/sparql
select ?bd where {
<http://dbpedia.org/resource/Mary_Shelley>
<http://dbpedia.org/ontology/birthDate> ?bd
}
select ?bp where {
<http://dbpedia.org/resource/Mary_Shelley>
<http://dbpedia.org/ontology/birthPlace> ?bp
}
PREFIX dbpedia:
<http://dbpedia.org/resource/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
select ?bc where {
dbpedia:Mary_Shelley dbpedia-owl:birthPlace
?bp .
?bp dbpedia-owl:country ?bc
}
function makeHTTPQuery($term){
$format = 'xml';
$query =
"PREFIX dbp: <http://dbpedia.org/resource/>
ont : <http://dbpedia.org/ontology/>
SELECT ?bd
WHERE {
dbp:$Mary_Shelly
ont:birthDate> ?bd
}";
$endpoint =
'http://dbpedia.org/sparql';
$searchUrl =
$endpoint.'
?'.'query='.urlencode($query).'&format='.$format;
return $searchUrl;
}//makeHTTPQuery
cURL
, response as an XML string :function sendQuery($searchUrl){
// get curl handle
$ch = curl_init();
// set request url
curl_setopt($ch, CURLOPT_URL, $searchUrl);
// set option "return response", don't print/echo
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// get the response
$response = curl_exec($ch);
curl_close($ch);
return $response;
}//sendQuery
function extractDate ($xmlString){
$splDoc = new SimpleXMLElement($xmlString);
$splDoc->registerXPathNamespace('s', 'http://www.w3.org/2005/sparql-results#');
$pathb = "/s:sparql/s:results/s:result/s:binding[@name='bd']/s:literal/text()";
$bds = $splDoc->xpath($pathb); // array
return $bds[0];
}//extractDate
decoDate.php
birthDate.php