« SPARQL Protocol and RDF Query Language/Le protocole SPARQL » : différence entre les versions

Contenu supprimé Contenu ajouté
m Robot : Correction et amélioration des liens wiki
Ligne 183 :
{{Exemple|titre=Exemple d'entête HTTP GET pour une requête SPARQL|contenu=
<source lang="text">
GET /sparql/?query='''EncodedQueryRequête_Encodée''' HTTP/1.1
Host: www.example.org
User-agent: my-sparql-client/0.1
</source>
Ligne 192 :
<source lang="text">
POST /sparql/ HTTP/1.1
Host: www.example.org
User-agent: sparql-client/0.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 94611001
 
query=VeryLongEncodedQueryTrès_Longue_Requête_Encodée&default-graph-uri=http://anotherlod.example/calendarbordercloud.rdfcom/mongraphe
</source>
}}
Ligne 219 :
===== Format SPARQL result XML =====
{{Exemple|titre=Exemple de session avec une requête SELECT|contenu=
Voici un exemple de requête SELECT :
<source lang="text">
select * where { ?x ?y ?z .} limit 5
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?book ?who
WHERE { ?book dc:creator ?who }
</source>
 
Cette requête aura comme entête HTTP :
<source lang="text">
GET /sparql/?query=EncodedQueryselect%20*%20where%20%20{%20?x%20?y%20?z%20.}%20limit%205 HTTP/1.1
Host: www.example.org
User-agent: my-sparql-clientFirefox/06.10
</source>
 
Ligne 236 ⟶ 234 :
<source lang="text">
HTTP/1.1 200 OK
Date: Fri, 0626 MayAug 20052011 2019:5517:1217 GMT
Server: Apache/12.2.3.29 (UnixCentOS) PHP/4.3.4 DAV/1.0.3
Connection: close
Content-Type: application/sparql-results+xml
</source>
 
Ligne 246 ⟶ 244 :
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
 
<variable name="x"/>
<head>
<variable name="booky"/>
<variable name="whoz"/>
</head>
<results>
<results distinct="false" ordered="false">
<result>
<binding name="bookx">
<uri>http://www.example.org/book/book5ID1</uri>
</binding>
<binding name="whoy"><bnode>r29392923r2922</bnode></binding>
<uri>http://xmlns.com/foaf/0.1/primaryTopic</uri>
</result>
</binding>
...
<binding name="z">
</sparql>
foaf:depiction <uri>http://www.example.org/joseID2</jose.jpguri>;
</binding>
</result>
...
</results>
</sparql>
</source>
}}
Ligne 264 ⟶ 270 :
Voici un exemple de requête '''ASK''' :
<source lang="text">
PREFIX dcex: <http://purlwww.example.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
ASK WHERE { ?book dc:creator "J.K. Rowling"}
ASK WHERE { ex:ID1 foaf:primaryTopic ex:ID2}
</source>
 
Cette requête aura comme entête HTTP :
<source lang="text">
GET /sparql/?query=EncodedQuery&default-graph-uri=httpPREFIX%20ex:%20%3Chttp://www.example.org/books%3E%20PREFIX%20foaf:%20%3Chttp://xmlns.com/foaf/0.1/%3E%20ASK%20WHERE%20{%20ex:ID1%20foaf:primaryTopic%20ex:ID2} HTTP/1.1
Host: www.example.org
User-agent: sparql-clientFirefox/06.10
</source>
 
Ligne 278 ⟶ 285 :
<source lang="text">
HTTP/1.1 200 OK
Date: Fri, 0626 MayAug 20052011 2019:4817:2517 GMT
Server: Apache/12.2.3.29 (UnixCentOS) PHP/4.3.4 DAV/1.0.3
Connection: close
Content-Type: application/sparql-results+xml
</source>
 
Ligne 296 ⟶ 303 :
===== Format SPARQL result JSON =====
{{Exemple|titre=Exemple de session avec une requête SELECT et en sortie du JSON|contenu=
Voici un exemple de requête SELECT :
<source lang="text">
select * where { ?x ?y ?z .} limit 5
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?book ?who
WHERE { ?book dc:creator ?who }
</source>
 
Cette requête aura comme entête HTTP :
<source lang="text">
GET /sparql/?query=EncodedQueryselect%20*%20where%20%20{%20?x%20?y%20?z%20.}%20limit%205&output=json HTTP/1.1
Host: www.example.org
User-agent: my-sparql-clientFirefox/06.10
</source>
 
Ligne 313 ⟶ 318 :
<source lang="text">
HTTP/1.1 200 OK
Date: Fri, 0626 MayAug 20052011 2019:5517:1217 GMT
Server: Apache/12.2.3.29 (UnixCentOS) PHP/4.3.4 DAV/1.0.3
Connection: close
Content-Type: application/sparql-results+xmljson
</source>
 
Ligne 323 ⟶ 328 :
<?xml version="1.0"?>
{
"head": { "vars": [ "bookx" , "whoy" , "z" ]
} ,
"results": {
"bindings": [
{
"bookx": { "type": "uri" , "value": "http://www.example.org/book/book6ID1" } ,
"whoy": { "type": "bnodeuri" , "value": "r29392923r2922http://xmlns.com/foaf/0.1/primaryTopic" } ,
"z": { "type": "uri" , "value": "http://www.example.org/ID2" }
} ,
...
Ligne 348 ⟶ 354 :
Voici un exemple de requête '''DESCRIBE''' :
<source lang="text">
PREFIX booksex: <http://www.example/book.org/>
DESCRIBE booksex:book6ID1
</source>
 
Cette requête aura comme entête HTTP :
<source lang="text">
GET /sparql/?query=EncodedQuery&default-graph-uri=httpPREFIX%20ex:%20%3Chttp://www.example.org/books%3E%20DESCRIBE%20ex:ID1 HTTP/1.1
Host: www.example.org
User-agent: sparql-clientFirefox/06.10
</source>
 
Ligne 362 ⟶ 368 :
<source lang="text">
HTTP/1.1 200 OK
Date: WedFri, 0326 Aug 20052011 1219:4817:2517 GMT
Server: Apache/12.2.3.29 (UnixCentOS) PHP/4.3.4 DAV/1.0.3
Connection: close
Content-Type: application/rdf+xml
</source>
 
Et la réponse contiendra le document turtleRDF XML:
<source lang="text">
<rdf:RDF ...
<?xml version="1.0"?>
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
<rdf:RDF ...
<rdf:Description rdf xmlns:aboutj.0="http://wwwxmlns.examplecom/bookfoaf/0.1/book6">
xmlns:j.1="http://purl.org/dc/terms/"
<dc:title>Example Book #6 </dc:title>
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description rdf:about="http://www.example.org/ID1">
<rdfs:label>Description of a document version of 13/11/2008</rdfs:label>
<j.1:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2008-11-03T20:37:51Z</j.1:created>
<j.1:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2008-11-03T21:12:31Z</j.1:modified>
<j.0:primaryTopic rdf:resource="http://www.example.org/ID2"/>
</rdf:Description>
</rdf:RDF>
Ligne 383 ⟶ 395 :
Voici un exemple de requête '''CONSTRUCT''' :
<source lang="text">
PREFIX rdfskos: <http://www.w3.org/19992008/0205/22-rdf-syntax-nsskos#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT { ?x skos:Concept ?z. ?x ?p ?v . }
PREFIX myfoaf: <http://www.example/jose/foaf.rdf#>
WHERE { ?x foaf:primaryTopic ?z. ?x ?p ?v . } LIMIT 5
 
CONSTRUCT { myfoaf:jose foaf:depiction <http://www.example/jose/jose.jpg>.
myfoaf:jose foaf:schoolHomepage <http://www.edu.example/>.
?s ?p ?o.}
WHERE { ?s ?p ?o. myfoaf:jose foaf:nick "Jo".
FILTER ( ! (?s = myfoaf:kendall && ?p = foaf:knows && ?o = myfoaf:edd )
&& ! ( ?s = myfoaf:julia && ?p = foaf:mbox && ?o = <mailto:julia@mail.example> )
&& ! ( ?s = myfoaf:julia && ?p = rdf:type && ?o = foaf:Person))
}
</source>
 
Cette requête aura comme entête HTTP :
<source lang="text">
GET /sparql?query=PREFIX%20skos:%20%3Chttp://www.w3.org/2008/05/skos%23%3E%20PREFIX%20foaf:%20%3Chttp://xmlns.com/foaf/0.1/%3E%20CONSTRUCT%20{...}%20WHERE%20{...}%20LIMIT%205&output=turtle HTTP/1.1
GET /sparql/?query=EncodedQuery&default-graph-uri=http://www.example/jose-foaf.rdf HTTP/1.1
Host: www.example.org
User-agent: sparql-clientFirefox/06.10
Accept: text/turtle, application/rdf+xml
</source>
 
Ligne 408 ⟶ 411 :
<source lang="text">
HTTP/1.1 200 OK
Date: Fri, 0626 MayAug 20052011 2019:5517:1117 GMT
Server: Apache/12.32.293 (UnixCentOS)
Connection: close
Content-Type: text/turtle
Ligne 418 ⟶ 421 :
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix myfoafrdfs: <http://www.examplew3.org/jose2000/01/foaf.rdf-schema#>.
@prefix skos: <http://www.w3.org/2008/05/skos#>.
PREFIX@prefix dcpurl: <http://purl.org/dc/elementsterms/1>.1/>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
PREFIX@prefix myfoafex: <http://www.example/jose/foaf.rdf#org/>.
 
ex:ID1 skos:Concept ex:ID2;
myfoaf:jose foaf:name "Jose Jimeñez";
foaf:primaryTopic ex:ID2;
foaf:depiction <http://www.example/jose/jose.jpg>;
rdfs:label "Description of a document foaf:nickversion "Joof 13/11/2008";
purl:created "2008-11-03T20:37:51Z"^^xsd:dateTime;
purl:modified "2008-11-03T21:12:31Z"^^xsd:dateTime.
...
</source>
}}
 
 
 
=== Protocole d'écriture ===