SPARQL Protocol for RDF /**/ pre.pbnf { border:1px dotted #cbb7fe; background-color: #e9feb7; padding:5px; width: 50%; margin-right: auto; color: black;} table {border: 2px black solid} span.hide {display: none} span.todo {color: red; font-weight: bold} span.warn {color: red;} p.desc {margin-left: 5%} p.capt {font-size: 75%; text-decoration: underline;} div.sig, span.sig {margin-left: 5%; padding: 1px; border: 2px solid #5080a6; background-color: #e9feb7; color: black;} dt {font-weight: bold;} span.note { font-size: 75%; } span.mci, span.ci, span.mxc {color: #655722; text-decoration: underline; text-transform: uppercase} pre.cvs-id {color: gray} code {text-decoration: underline} .req { background-color: #fff; border-width: 1px 1px 1px 1px; border-style: solid; overflow: auto; padding: 1em; border-color: #fc3; } .resp { background-color: #fff; border-width: 1px 1px 1px 1px; border-style: solid; overflow: auto; padding: 1em; border-color: #ab5;}
.query { background-color: #fff; border-width: 1px 1px 1px 1px; border-style: solid; overflow: auto; padding: 1em; border-color: #7cc;} .pair {border:2px solid black;} /**/ SPARQL Protocol for RDF W3C Recommendation 15 January 2008 New Version Available: SPARQL 1.1 The SPARQL Working Group has produced a W3C Recommendation for a new version of SPARQL which adds features to this 2008 version. Please see SPARQL 1.1 Overview This version: http://www.w3.org/TR/2008/REC-rdf-sparql-protocol-20080115/ Latest published version: http://www.w3.org/TR/rdf-sparql-protocol/ Previous version: http://www.w3.org/TR/2007/PR-rdf-sparql-protocol-20071112/ Editors: Kendall Grant Clark, < [email protected] Clark & Parsia LLC Lee Feigenbaum, < [email protected] Elias Torres, < [email protected] IBM Corporation Please refer to the errata See also translations Copyright W3C ® MIT ERCIM Keio liability trademark document use Abstract The SPARQL Protocol and RDF Query Language ( SPARQL RDF WSDL 2.0 W3C RDF Data Access Working Group Semantic Web Activity activity statement Status of This Document This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index This is a W3C Recommendation This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web. Comments on this document should be sent to [email protected] public archive [email protected] public archive This document was produced by the RDF Data Access Working Group W3C Semantic Web Activity comments received issues one editorial change November 2007 Proposed Recommendation The Working Group's SPARQL Protocol Implementation Report April 2006 Candidate Recommendation The Data Access Working Group has postponed 12 issues, including aggregate functions an update language This document was produced by a group operating under the 5 February 2004 W3C Patent Policy public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy Table of Contents 1. Introduction 2. SPARQL Protocol 2.1 SparqlQuery 2.1.1 query 2.1.2 query 2.1.3 query 2.1.4 query 2.2 HTTP Bindings 2.2.1 HTTP Examples 2.2.1.1 SELECT 2.2.1.2 SELECT 2.2.1.3 CONSTRUCT 2.2.1.4 ASK 2.2.1.5 DESCRIBE 2.2.1.6 SELECT 2.2.1.7 SELECT 2.2.1.8 SELECT 2.2.1.9 SELECT 2.2.1.10 SELECT 2.2.1.11 Very long SELECT 2.2.1.12 SELECT 2.2.1.13 SELECT 2.3 SOAP Bindings 2.3.1 SOAP Example 3. Policy Considerations 3.1 Security 4. Conformance 5. References 5.1 Normative 5.2 Informative 6. Acknowledgments 1. Introduction This document (which refers to itself as "SPARQL Protocol for RDF") describes SPARQL Protocol, a means of conveying SPARQL queries from query clients to query processors. SPARQL Protocol has been designed for compatibility with the SPARQL Query Language for RDF When this document uses the words must must not should should not may recommended RFC 2119 When this document contains excerpts from other documents, including WSDL and XML Schema instances, it uses the following namespace prefixes and namespace URIs: Prefix Namespace URI st http://www.w3.org/2005/09/sparql-protocol-types/# xs http://www.w3.org/2001/XMLSchema vbr http://www.w3.org/2005/sparql-results# rdf http://www.w3.org/1999/02/22-rdf-syntax-ns# whttp http://www.w3.org/2006/01/wsdl/http wsoap http://www.w3.org/2006/01/wsdl/soap soap http://www.w3.org/2003/05/soap-envelope wsdlx http://www.w3.org/2005/08/wsdl-extensions tns http://www.w3.org/2005/08/sparql-protocol-query/# 2. SPARQL Protocol This set of documents comprises the specification of the SPARQL Protocol: SPARQL Protocol for RDF The current document which normatively specifies the SPARQL Protocol in human-readable language. SPARQL Protocol WSDL 2.0 Description The normative description of the SPARQL Protocol using WSDL 2.0. SPARQL Protocol Types The XML Schema document that normatively defines the types used in SPARQL Protocol. SPARQL Protocol contains one interface, SparqlQuery query described abstractly WSDL 2.0 2.1 SparqlQuery Interface 2.1.1 query SparqlQuery query SPARQL query string RDF dataset The query In-Out message exchange pattern This pattern consists of exactly two messages, in order, as follows: A message: indicated by a Interface Message Reference component whose {message label} is "In" and {direction} is "in" received from some node N A message: indicated by a Interface Message Reference component whose {message label} is "Out" and {direction} is "out" sent to node N This pattern uses the rule 2.2.1 Fault Replaces Message This interface and its operation are described in the following WSDL 2.0 fragment (from protocol-query.wsdl <!-- Abstract SparqlQuery Interface --> <interface name=" SparqlQuery http://www.w3.org/2006/01/wsdl/style/iri MalformedQuery st:malformed-query QueryRequestRefused st:query-request-refused query http://www.w3.org/2006/01/wsdl/in-out In st:query-request Out st:query-result Excerpt 1.0 WSDL 2.0 fragment 2.1.2 query Abstractly, the contents of the In Message of SparqlQuery query st:query-request SPARQL query string RDF dataset query defined default-graph-uri named-graph-uri FROM FROM NAMED These types are defined in the following XML Schema fragment, from protocol-types.xsd <xs:element name=" query-request query default-graph-uri named-graph-uri Excerpt 1.1 XML Schema fragment Specifying an RDF Dataset The RDF dataset may be specified either in a [SPARQL] query using FROM FROM NAMED Resolving an Ambiguous RDF Dataset In the case where both the query and the protocol specify an RDF dataset, but not the identical RDF dataset, the dataset specified in the protocol must SparqlQuery query Rejecting Query Requests to RDF Datasets A conformant SPARQL Protocol service may conformant SPARQL Protocol service may conformant SPARQL Protocol may query QueryRequestRefused Determining the Base IRI The BASE Uniform Resource Identifier (URI): Generic Syntax RFC3986 may 2.1.3 query Abstractly, the contents of the Out Message of SparqlQuery query query-result a SPARQL Results Document SELECT ASK an RDF graph [RDF-Concepts] serialized, for example, in the RDF/XML syntax DESCRIBE CONSTRUCT The query-result protocol-types.xsd <xs:element name=" query-result vbr:sparql rdf:RDF Excerpt 1.2 XML Schema fragment 2.1.4 query [WSDL2-Adjuncts] defines several fault propagation rules which specify how operation faults and messages interact. The query Fault Replaces Message Any message after the first in the pattern may must must must Thus, the query SparqlQuery Out Message MalformedQuery QueryRequestRefused protocol-types.xsd <xs:element type="xs:string" name=" fault-details malformed-query st:fault-details query-request-refused st:fault-details Excerpt 1.3 XML Schema fragment MalformedQuery When the value of the query MalformedQuery QueryRequestRefused must Fault Replaces Message Rule MalformedQuery Out Message must not When the MalformedQuery must fault-details QueryRequestRefused This WSDL fault message should QueryRequestRefused conformant SPARQL service When the QueryRequestRefused must fault-details 2.2 HTTP Bindings The SparqlQuery query conformant SPARQL Protocol service must SparqlQuery must protocol-query.wsdl may 2.3 SOAP Bindings [WSDL2-Adjuncts] defines a means of binding abstract interface operations to HTTP. The HTTP bindings for the query protocol-query.wsdl <!-- the HTTP GET binding for query operation --> <binding name=" queryHttpGet GET */* application/x-www-form-urlencoded application/sparql-results+xml, application/rdf+xml, */* queryHttpPost POST */* application/x-www-form-urlencoded, application/xml application/sparql-results+xml, application/rdf+xml, */* There are two HTTP bindings, queryHttpGet queryHttpPost SparqlQuery SparqlQuery MalformedQuery QueryRequestRefused HTTP status codes 400 Bad Request 500 Internal Server Error The queryHttpGet should queryHttpPost should An Informative Note About Serialization Constraints. queryHttpGet queryHttpPost queryHttpGet queryHttpPost conformant SPARQL Protocol service queryHttpGet This binding of the query GET whttp:faultSerialization */* whttp:inputSerialization application/x-www-form-urlencoded whttp:outputSerialization application/sparql-results+xml application/rdf+xml */* queryHttpPost This binding of the query POST whttp:faultSerialization */* whttp:inputSerialization application/x-www-form-urlencoded application/xml whttp:outputSerialization application/sparql-results+xml application/rdf+xml */* 2.2.1 HTTP Examples The following abstract HTTP trace examples illustrate invocation of the query EncodedQuery default-graph-uri named-graph-uri 2.2.1.1 SELECT with service-supplied RDF dataset This SPARQL query PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?book ?who WHERE { ?book dc:creator ?who } is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery That query against the service-supplied RDF dataset, executed by that SPARQL query service, returns the following query result: HTTP/1.1 200 OK Date: Fri, 06 May 2005 20:55:12 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head> <variable name="book"/> <variable name="who"/> </head> <results distinct="false" ordered="false"> <result> <binding name="book"><uri>http://www.example/book/book5</uri></binding> <binding name="who"><bnode>r29392923r2922</bnode></binding> </result> ... <result> <binding name="book"><uri>http://www.example/book/book6</uri></binding> <binding name="who"><bnode>r8484882r49593</bnode></binding> </result> </results> 2.2.1.2 SELECT with simple RDF dataset This SPARQL query PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?book ?who WHERE { ?book dc:creator ?who } is conveyed to the SPARQL query service, http://www.other.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri That query — against the RDF dataset identified by the value of the default-graph-uri http://www.other.example/books HTTP/1.1 200 OK Date: Fri, 06 May 2005 20:55:12 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="book"/> <variable name="who"/> </head> ... <results distinct="false" ordered="false"> <result> <binding name="book"><uri>http://www.example/book/book2</uri></binding> <binding name="who"><bnode>r1115396427r1133</bnode></binding> </result> <result> <binding name="book"><uri>http://www.example/book/book3</uri></binding> <binding name="who"><bnode>r1115396427r1133</bnode></binding> </result> <result> <binding name="book"><uri>http://www.example/book/book1</uri></binding> <binding name="who"><literal>J.K. Rowling</literal></binding> </result> </results> 2.2.1.3 CONSTRUCT with simple RDF dataset and HTTP content negotiation This SPARQL query PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX myfoaf: <http://www.example/jose/foaf.rdf#>
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:[email protected]> ) && ! ( ?s = myfoaf:julia && ?p = rdf:type && ?o = foaf:Person)) } is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri With the response illustrated here: HTTP/1.1 200 OK Date: Fri, 06 May 2005 20:55:11 GMT Server: Apache/1.3.29 (Unix) Connection: close Content-Type: text/turtle
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix foaf: <http://xmlns.com/foaf/0.1/>. @prefix myfoaf: <http://www.example/jose/foaf.rdf#>.
myfoaf:jose foaf:name "Jose Jimeñez"; foaf:depiction <http://www.example/jose/jose.jpg>; foaf:nick "Jo"; ... foaf:schoolHomepage <http://www.edu.example/>; foaf:workplaceHomepage <http://www.corp.example/>; foaf:homepage <http://www.example/jose/>; foaf:knows myfoaf:juan; rdf:type foaf:Person.
myfoaf:juan foaf:mbox <mailto:[email protected]>; rdf:type foaf:Person. Note: text/turtle http://www.w3.org/TeamSubmission/turtle 2.2.1.4 ASK with simple RDF dataset This SPARQL query PREFIX dc: <http://purl.org/dc/elements/1.1/> ASK WHERE { ?book dc:creator "J.K. Rowling"} is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri With the response illustrated here: HTTP/1.1 200 OK Date: Fri, 06 May 2005 20:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head></head> <boolean>true</boolean> </sparql> 2.2.1.5 DESCRIBE with simple RDF dataset This SPARQL query PREFIX books: <http://www.example/book/> DESCRIBE books:book6 is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri With the response illustrated here: HTTP/1.1 200 OK Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/rdf+xml
<?xml version="1.0"?> <rdf:RDF ... xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:books="http://www.example/book/" xmlns:dc="http://purl.org/dc/elements/1.1/" 2.2.1.6 SELECT with complex RDF dataset This SPARQL query PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?who ?g ?mbox WHERE { ?g dc:publisher ?who . GRAPH ?g { ?x foaf:mbox ?mbox } } is conveyed to the SPARQL query service, http://www.example/sparql/, as illustrated here (with line breaks for legibility): GET /sparql/? query EncodedQuery default-graph-uri default-graph-uri named-graph-uri named-graph-uri named-graph-uri named-graph-uri With the response illustrated here: HTTP/1.1 200 OK Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="who"/> <variable name="g"/> <variable name="mbox"/> </head> ... <results ordered="false" distinct="false"> <result> <binding name="who"> <literal>Alice</literal> </binding> <binding name="g"> <uri>http://your.example/foaf-alice</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> <result> <binding name="who"> <literal>Bob</literal> </binding> <binding name="g"> <uri>http://www.example/foaf-bob</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> <result> <binding name="who"> <literal>Susan</literal> </binding> <binding name="g"> <uri>http://www.example/foaf-susan</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> <result> <binding name="who"> <literal>John</literal> </binding> <binding name="g"> <uri>http://this.example/john/foaf</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> </results> 2.2.1.7 SELECT with query-only RDF dataset This SPARQL query PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?who ?g ?mbox FROM <http://www.example/publishers> FROM NAMED <http://www.example/alice> FROM NAMED <http://www.example/bob> WHERE { ?g dc:publisher ?who . GRAPH ?g { ?x foaf:mbox ?mbox } } is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery With the response illustrated here: HTTP/1.1 200 OK Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> ... <head> <variable name="who"/> <variable name="g"/> <variable name="mbox"/> </head> <results ordered="false" distinct="false"> <result> <binding name="who"> <literal>Bob Hacker</literal> </binding> <binding name="g"> <uri>http://www.example/bob</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> <result> <binding name="who"> <literal>Alice Hacker</literal> </binding> <binding name="g"> <uri>http://www.example/alice</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> </results> 2.2.1.8 SELECT with ambiguous RDF dataset This SPARQL query PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?who ?g ?mbox FROM <http://www.example/publishers> FROM NAMED <http://www.example/john> FROM NAMED <http://www.example/susan> WHERE { ?g dc:publisher ?who . GRAPH ?g { ?x foaf:mbox ?mbox } } is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri named-graph-uri named-graph-uri This protocol operation contains an ambiguous RDF dataset: the dataset specified in the query is different than the one specified in the protocol (by way of default-graph-uri named-graph-uri HTTP/1.1 200 OK Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="who"/> <variable name="g"/> <variable name="mbox"/> </head> <results ordered="false" distinct="false"> <result> <binding name="who"> <literal>Bob Hacker</literal> </binding> <binding name="g"> <uri>http://www.example/bob</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> <result> <binding name="who"> <literal>Alice Hacker</literal> </binding> <binding name="g"> <uri>http://www.example/alice</uri> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result> </results> </sparql> 2.2.1.9 SELECT with malformed query fault This syntactically invalid SPARQL query PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name WHERE { ?x foaf:name ?name ORDER BY ?name } is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri With the response — the MalformedQuery 2.1 SparqlQuery HTTP/1.1 400 Bad Request Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: text/plain; charset=UTF-8
4:syntax error, unexpected ORDER, expecting '}' 2.2.1.10 SELECT with query request refused fault This SPARQL query PREFIX bio: <http://bio.example/schema/#> SELECT ?valence FROM <http://another.example/protein-db.rdf> WHERE { ?x bio:protein ?valence } ORDER BY ?valence is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery default-graph-uri With the response — the QueryRequestRefused 2.1 SparqlQuery HTTP/1.1 500 Internal Server Error Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: text/html; charset=UTF-8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>SPARQL Processing Service: Query Request Refused</title> </head> <body> <p> Query Request Refused: your request could not be processed because <code>http://another.example/protein-db.rdf</code> could not be retrieved within the time alloted.</p> </body> </html> 2.2.1.11 Very long SELECT query using POST binding Some SPARQL queries, perhaps machine generated, may be longer than can be reliably conveyed by way of the HTTP GET binding described in 2.2 HTTP Bindings PREFIX : <http://www.w3.org/2002/12/cal/icaltzd#> PREFIX Chi: <http://www.w3.org/2002/12/cal/test/Chiefs.ics#> PREFIX New: <http://www.w3.org/2002/12/cal/tzd/America/New_York#> PREFIX XML: <http://www.w3.org/2001/XMLSchema#>
SELECT ?summary WHERE { { Chi:D603E2AC-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-09-08T16:00:00"^^New:tz; :dtstamp "2002-09-06T03:09:27Z"^^XML:dateTime; :dtstart "2002-09-08T13:00:00"^^New:tz; :summary ?summary; :uid "D603E2AC-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D603E90B-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-09-15T16:00:00"^^New:tz; :dtstamp "2002-09-06T03:10:19Z"^^XML:dateTime; :dtstart "2002-09-15T13:00:00"^^New:tz; :summary ?summary; :uid "D603E90B-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D603ED6E-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-09-22T16:00:00"^^New:tz; :dtstamp "2002-09-06T03:11:05Z"^^XML:dateTime; :dtstart "2002-09-22T13:00:00"^^New:tz; :summary ?summary; :uid "D603ED6E-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D603F18C-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-09-29T16:00:00"^^New:tz; :dtstamp "2002-09-06T03:15:46Z"^^XML:dateTime; :dtstart "2002-09-29T13:00:00"^^New:tz; :summary ?summary; :uid "D603F18C-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D603F5B7-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-11-04"^^XML:date; :dtstamp "2002-09-06T03:12:53Z"^^XML:dateTime; :dtstart "2002-11-03"^^XML:date; :summary ?summary; :uid "D603F5B7-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D603F9D7-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-11-10T20:15:00"^^New:tz; :dtstamp "2002-09-06T03:14:12Z"^^XML:dateTime; :dtstart "2002-11-10T17:15:00"^^New:tz; :summary ?summary; :uid "D603F9D7-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D604022C-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-11-17T17:00:00"^^New:tz; :dtstamp "2002-09-06T03:14:51Z"^^XML:dateTime; :dtstart "2002-11-17T14:00:00"^^New:tz; :summary ?summary; :uid "D604022C-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D604065C-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-10-06T19:05:00"^^New:tz; :dtstamp "2002-09-06T03:16:54Z"^^XML:dateTime; :dtstart "2002-10-06T16:05:00"^^New:tz; :summary ?summary; :uid "D604065C-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6040A7E-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-10-13T19:15:00"^^New:tz; :dtstamp "2002-09-06T03:17:51Z"^^XML:dateTime; :dtstart "2002-10-13T16:15:00"^^New:tz; :summary ?summary; :uid "D6040A7E-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6040E96-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-10-20T16:00:00"^^New:tz; :dtstamp "2002-09-06T03:18:32Z"^^XML:dateTime; :dtstart "2002-10-20T13:00:00"^^New:tz; :summary ?summary; :uid "D6040E96-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6041270-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-10-27T17:00:00"^^New:tz; :dtstamp "2002-09-06T03:19:15Z"^^XML:dateTime; :dtstart "2002-10-27T14:00:00"^^New:tz; :summary ?summary; :uid "D6041270-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6041673-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-11-24T20:05:00"^^New:tz; :dtstamp "2002-09-06T03:22:09Z"^^XML:dateTime; :dtstart "2002-11-24T17:05:00"^^New:tz; :summary ?summary; :uid "D6041673-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6041A73-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-12-01T17:00:00"^^New:tz; :dtstamp "2002-09-06T03:22:52Z"^^XML:dateTime; :dtstart "2002-12-01T14:00:00"^^New:tz; :summary ?summary; :uid "D6041A73-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D60421EF-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-12-08T17:00:00"^^New:tz; :dtstamp "2002-09-06T03:24:04Z"^^XML:dateTime; :dtstart "2002-12-08T14:00:00"^^New:tz; :summary ?summary; :uid "D60421EF-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6042660-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-12-15T20:05:00"^^New:tz; :dtstamp "2002-09-06T03:25:03Z"^^XML:dateTime; :dtstart "2002-12-15T17:05:00"^^New:tz; :summary ?summary; :uid "D6042660-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6042A93-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-12-22T17:00:00"^^New:tz; :dtstamp "2002-09-06T03:25:47Z"^^XML:dateTime; :dtstart "2002-12-22T14:00:00"^^New:tz; :summary ?summary; :uid "D6042A93-C1C9-11D6-9446-003065F198AC" . } UNION { Chi:D6042EDF-C1C9-11D6-9446-003065F198AC a :Vevent; :dtend "2002-12-28T21:00:00"^^New:tz; :dtstamp "2002-09-06T03:26:51Z"^^XML:dateTime; :dtstart "2002-12-28T18:00:00"^^New:tz; :summary ?summary; :uid "D6042EDF-C1C9-11D6-9446-003065F198AC" . } } is conveyed to the SPARQL query service, http://www.example/sparql/ POST /sparql/ HTTP/1.1 Host: www.example User-agent: sparql-client/0.1 Content-Type: application/x-www-form-urlencoded Content-Length: 9461 query EncodedQuery default-graph-uri With the response illustrated here: HTTP/1.1 200 OK Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="summary"/> </head> <results ordered="false" distinct="false"> <result> <binding name="summary"> <literal>Chiefs vs. Cleveland @ Cleveland Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Jacksonville @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. New England @ Gillette Stadium</literal> </binding> </result> ... <result> <binding name="summary"> <literal>Chiefs vs. Miami @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>BYE</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. San Francisco @ 49ers Stadium at Candlestick Point</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Buffalo @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. NY Jets @ Giants Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. San Diego @ Qualcomm Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Denver @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Oakland @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Seattle @ Seahawks Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Arizona @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. St. Louis @ Arrowhead Stadium</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. Denver @ INVESCO Field at Mile High</literal> </binding> </result> <result> <binding name="summary"> <literal>Chiefs vs. San Diego @ Arrowhead Stadium</literal> </binding> </result> 2.2.1.12 SELECT with internationalization SPARQL queries may include internationalized characters or character sets. This SPARQL query PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX 食: <http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#> SELECT ?name ?food WHERE { [ foaf:name ?name ; 食:食べる ?food ] . } is conveyed to the SPARQL query service, http://www.example/sparql/ GET /sparql/? query EncodedQuery HTTP/1.1 200 OK Date: Wed, 03 Aug 2005 12:48:25 GMT Server: Apache/1.3.29 (Unix) Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> ... 2.2.1.13 SELECT with queryHttpPost binding and XML input In some future version SPARQL queries could be serialized as XML POST <?xml version="1.0"?> <rdf-query xmlns="http://example.org/SparqlX/"> <select><variable name="book"/><variable name="who"/></select> <query-pattern> <triple-pattern> <subject><variable name="book"/></subject> <predicate><uri>http://purl.org/dc/elements/1.1/creator</uri></predicate> <object><variable name="who"/></object> </triple-pattern> </query-pattern> </rdf-query> is conveyed to the SPARQL query service, http://www.example/sparql/ POST /sparql/ HTTP/1.1 Host: www.example User-agent: my-sparql-client/0.1 Content-type: application/xml That query against the service-supplied RDF dataset, executed by that SPARQL query service, returns the following query result: HTTP/1.1 200 OK Date: Fri, 06 May 2005 20:55:12 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/sparql-results+xml
<?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head> <variable name="book"/> <variable name="who"/> </head> <results distinct="false" ordered="false"> <result> <binding name="book"><uri>http://www.example/book/book5</uri></binding> <binding name="who"><bnode>r29392923r2922</bnode></binding> </result> ... <result> <binding name="book"><uri>http://www.example/book/book6</uri></binding> <binding name="who"><bnode>r8484882r49593</bnode></binding> </result> </results> 2.3 SOAP Bindings [WSDL2-Adjuncts] defines a means of binding abstract interface operations to SOAP. The SOAP bindings for the query protocol-query.wsdl <binding name="querySoap" interface="SparqlQuery" type="http://www.w3.org/2006/01/wsdl/soap" wsoap:version="1.2" wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP">
<fault ref="tns:MalformedQuery" wsoap:code="soap:Sender" /> <fault ref="tns:QueryRequestRefused" wsoap:code="soap:Sender" />
<operation ref="tns:query" wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
</binding> The name of the SOAP binding of SparqlQuery query querySoap type 1.2 wsoap:protocol {http://www.w3.org/2006/01/wsdl/soap, protocol} http://www.w3.org/2003/05/soap/bindings/HTTP must protocol-query.wsdl wsoap:protocol The two fault SparqlQuery Finally, the operation query SparqlQuery Excerpt 1.0 wsoap:mep http://www.w3.org/2003/05/soap/mep/request-response POST 2.3.1 SOAP Example POST /services/sparql-query HTTP/1.1 Content-Type: application/soap+xml Accept: application/soap+xml, multipart/related, text/* User-Agent: Axis/1.2.1 Host: www.example SOAPAction: "" Content-Length: 438
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <query-request xmlns="http://www.w3.org/2005/09/sparql-protocol-types/#"> <query>SELECT ?z {?x ?y ?z . FILTER regex(?z, 'Harry')}</query> </query-request> </soapenv:Body> </soapenv:Envelope> HTTP/1.1 200 OK Content-Type: application/soap+xml
<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <query-result xmlns="http://www.w3.org/2005/09/sparql-protocol-types/#"> <ns1:sparql xmlns:ns1="http://www.w3.org/2005/sparql-results#"> <ns1:head> <ns1:variable name="z"/> </ns1:head> <ns1:results distinct="false" ordered="false"> <ns1:result> <ns1:binding name="z"> <ns1:literal>Harry Potter and the Chamber of Secrets</ns1:literal> </ns1:binding> </ns1:result> ... <ns1:result> <ns1:binding name="z"> <ns1:literal>Harry Potter and the Half-Blood Prince</ns1:literal> </ns1:binding> </ns1:result> <ns1:result> <ns1:binding name="z"> <ns1:literal>Harry Potter and the Goblet of Fire</ns1:literal> </ns1:binding> </ns1:result> <ns1:result> <ns1:binding name="z"> <ns1:literal>Harry Potter and the Philosopher's Stone</ns1:literal> </ns1:binding> </ns1:result> <ns1:result> <ns1:binding name="z"> <ns1:literal>Harry Potter and the Order of the Phoenix</ns1:literal> </ns1:binding> </ns1:result> <ns1:result> <ns1:binding name="z"> <ns1:literal>Harry Potter and the Prisoner Of Azkaban</ns1:literal> </ns1:binding> </ns1:result> 3. Policy Considerations 3.1 Security There are at least two possible sources of denial-of-service attacks against SPARQL protocol services. First, under-constrained queries can result in very large numbers of results, which may require large expenditures of computing resources to process, assemble, or return. Another possible source are queries containing very complex — either because of resource size, the number of resources to be retrieved, or a combination of size and number — RDF dataset descriptions, which the service may be unable to assemble without significant expenditure of resources, including bandwidth, CPU, or secondary storage. In some cases such expenditures may effectively constitute a denial-of-service attack. A SPARQL protocol service may Since a SPARQL protocol service may make HTTP requests of other origin servers on behalf of its clients, it may be used as a vector of attacks against other sites or services. Thus, SPARQL protocol services may effectively act as proxies for third-party clients. Such services may may SPARQL protocol services may may refuse to process such query requests Different IRIs may have the same appearance. Characters in different scripts may look similar (a Cyrillic "о" may appear similar to a Latin "o"). A character followed by combining characters may have the same visual representation as another character (LATIN SMALL LETTER E followed by COMBINING ACUTE ACCENT has the same visual representation as LATIN SMALL LETTER E WITH ACUTE). Users of SPARQL must take care to construct queries with IRIs that match the IRIs in the data. Further information about matching of similar characters can be found in Unicode Security Considerations Internationalized Resource Identifiers (IRIs) 4. Conformance The status of the parts of SPARQL Protocol for RDF (this document) is as follows: Section 1 Introduction: normative Section 2 SPARQL Protocol: normative An Informative Note About Serialization Constraints informative Subsection 2.2.1 HTTP Examples: informative Subsection 2.3.1 SOAP Example: informative Section 3: Policy Considerations: normative Section 4: Conformance: normative Section 5.1: Normative References: normative Section 5.2: Informative References: informative Section 6: Acknowledgments: informative Further, both protocol-query.wsdl protocol-types.xsd normative A conformant SPARQL Protocol service must SparqlQuery may query SparqlQuery must query protocol-query.wsdl protocol-types.xsd may query must 3. Policy Considerations 5. References 1. Normative [RFC2119] Key words for use in RFCs to Indicate Requirement Levels [RFC3987] Internationalized Resource Identifiers (IRIs) [RFC3986] Uniform Resource Identifier (URI): Generic Syntax [HTTP] Hypertext Transfer Protocol -- HTTP/1.1 Resource Description Framework (RDF): Concepts and Abstract Syntax Latest version [RDF-Syntax] RDF/XML Syntax Specification (Revised) Latest version [SOAP12] SOAP Version 1.2 Part 2: Adjuncts Latest version [SPARQL] SPARQL Query Language for RDF Latest version [SRD] SPARQL Query Results XML Format Latest version WSDL2 Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language Latest version WSDL2-Adjuncts Web Services Description Language (WSDL) Version 2.0 Part 2: Adjuncts Latest version 2. Informative [UC&R] RDF Data Access Use Cases and Requirements Latest version [WSDL2-Primer] Web Services Description Language (WSDL) Version 2.0 Part 0: Primer Latest version [UNISEC] Unicode Security Considerations 6. Acknowledgments My thanks to members of DAWG, especially Bijan Parsia, Bryan Thompson, Andy Seaborne, Steve Harris, Eric Prud'hommeaux, Yoshio FUKUSHIGE, Howard Katz, Dirk-Willem van Gulik, Dan Connolly, and Lee Feigenbaum. Particular thanks are owed to Elias Torres for his generous assistance and support. Thanks as well to my UMD colleagues Jim Hendler, Ron Alford, Amy Alford, Yarden Katz, Chris Testa, and members of the Mindlab Semantic Web Undergraduate Social. Particular thanks are also owed my NASA colleague and friend, Andy Schain. I also thank Jacek Kopecky, Morten Frederiksen, Mark Baker, Jan Algermissen, Danny Ayers, Bernd Simon, Graham Klyne, Arjohn Kampman, Tim Berners-Lee, Dan Brickley, Patrick Stickler, Karl Dubost, Jonathan Marsh, Leigh Dodds, David Wood, Reto Krummenacher, Thomas Roessler, Danny Weitzner, Paul Downey, Hugo Haas, Richard Newman. Change Log There has been one change since the November 2007 Proposed Recommendation CONSTRUCT with simple RDF text/turtle