Copyright ©2005 W3C ® ( MIT , ERCIM , Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
The RDF Query Language SPARQL expresses queries over RDF graphs. This document employes WSDL 2.0 to define a protocol for conveying those queries, as well as other operations, to an RDF query processing services and conveying the results of such queries and operations to the entity that requested them. This document also describes an RDF vocabulary for describing the capabilities and characteristics of RDF query processors. This protocol is being developed by the W3C RDF Data Access Working Group (DAWG), part of the Semantic Web Activity as described in the activity statement .
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 at http://www.w3.org/TR/.
This is the second Public Working Draft of the SPARQL protocol produced by the RDF Data Access Working Group, (part of the Semantic Web Activity) for review by W3C Members and other interested parties. It reflects the best effort of the editors to reflect implementation experience and incorporate input from various members of the WG, but is not yet endorsed by the WG as a whole. This document defines an abstract protocol and a concrete binding to HTTP. The Working Group would appreciate community feedback on that protocol and binding. Please send comments to the public public-rdf-dawg-comments@w3.org, a mailing list with a public archive.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced under the 5 February 2004 W3C Patent Policy. The Working Group maintains a public list of patent disclosures relevant to this document; that page also includes instructions for disclosing [and excluding] a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) with respect to this specification should disclose the information in accordance with section 6 of the W3C Patent Policy.
This document describes SPARQL Protocol, a means of conveying RDF queries from query clients to query processors. The SPARQL Protocol has been designed for compatability with the SPARQL Query Language for RDF [SPARQL]. SPARQL Protocol is described in two ways: first, as an interface independent of any concrete realization, implementation, or binding to another protocol; second, as an HTTP binding of this interface.
When this document uses the words must, must not, should, should not, may and recommended, and the words appear as emphasized text, they must be interpreted as described in RFC 2119 [RFC2119].
The SPARQL protocol contains one interface,
SparqlQuery
, with one operation, query
. The
protocol is described
abstractly, using WSDL
2.0 [WSDL2]; is described in terms of a web service that implements
its interface, types, faults, and operations; and is described
concretely by HTTP bindings.
query
operationSparqlQuery
is the only interface of SPARQL Protocol.
It contains one operation, query
, which is used to convey
a SPARQL
query -- including a SPARQL query
string and an RDF dataset -- and a query result between clients
(requesters) and services (responders).
The query
operation is described as an
In-Out
message exchange pattern, which is taken from [WSDL-Adjuncts]. The
constraints of an In-Out message exchange pattern are as follows:
This pattern consists of exactly two messages, in order, as follows:
A message:
indicated by a Message Label component whose {message label} is 'In' and {direction} is 'in'
received from some node N
A message:
indicated by a Message Label component whose {message label} is 'Out' and {direction} is 'out'
sent to node N
This pattern uses the rule 2.1.1 Fault Replaces Message.
This interface and its operation are described in the following WSDL 2.0 fragment (from sparql-protocol-query.wsdl):
<interface name="SparqlQuery" styleDefault="http://www.w3.org/2005/05/wsdl/style/uri"> <operation name="query" pattern="http://www.w3.org/2004/08/wsdl/in-out" safe="true"> <documentation>The operation is used to convey queries and their results.</documentation> <input messageLabel="In" element="st:query"></input> <output messageLabel="Out" element="st:query-result"></output> </operation> </interface>
query
In Message
Abstractly, the contents of the In
Message of SparqlQuery
's query
operation is an XML Schema complex type, called
st:query
in Figure 1.0, composed of two further
parts: one SPARQL
query string; and zero (can there be zero
datasets?) or one RDF
dataset. The SPARQL query string, represented in the message
schema by sparql-query
, is defined
by [SPARQL] as "a sequence of characters in the language defined
by the [SPARQL] grammar, starting with the Query
production". Should this definition be inlined
here or just hyperlinked to the QL spec?.
The RDF dataset is composed of one default or background RDF graph,
identified by one default-graph-uri
type; and by zero
or more named RDF graphs, identified by zero or more
named-graph-uri
types. These correspond to the
FROM
and FROM NAMED
keywords in [SPARQL],
respectively.
The RDF dataset may be specified either in a legal [SPARQL] query using
FROM
and FROM NAMED
keywords; or it may be
specified in the protocol described in this document; or it may be
specified in both the query proper and in the protocol. 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 be the RDF dataset consumed by
SparqlQuery
's query
operation.
These types are defined in the following XML Schema fragment, from sparql-protocol-types.xsd:
<xs:element name="query"> <xs:complexType> <xs:all> <xs:element minOccurs="1" maxOccurs="1" name="sparql-query" type="xs:string"></xs:element> <xs:element minOccurs="0" maxOccurs="1" ref="rdf-dataset"></xs:element> </xs:all> </xs:complexType> </xs:element> <xs:element name="rdf-dataset"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="1" name="default-graph-uri" type="xs:anyURI"></xs:element> <xs:element minOccurs="0" maxOccurs="unbounded" name="named-graph-uri" type="xs:anyURI"></xs:element> </xs:sequence> </xs:complexType> </xs:element>
Figure 1.1 XML Schema fragment
query
Out MessageAbstractly, the contents of the Out
Message of SparqlQuery
's query
operation
is an XML Schema complex type, called query-result
in
Figure 1.2, composed of either one or the other of two further
elements:
The query-result
type is defined in this W3C XML
Schema fragment, from sparql-protocol-types.xsd:
<xs:element name="query-result"> <xs:complexType> <xs:choice> <xs:element minOccurs="0" maxOccurs="1" ref="vbr:sparql"/> <xs:element minOccurs="0" maxOccurs="1" ref="rdf:RDF"/> </xs:choice> </xs:complexType> </xs:element>
Figure 1.2 XML Schema fragment
query
Fault Messages[WSDL2-Adjuncts] defines several fault propagation rules which
specify how operation faults and messages
interact. The query
operation described here relies on
the Fault
Replaces Message rule:
Any message after the first in the pattern may be replaced with a fault message, which must have identical direction. The fault message must be delivered to the same target node as the message it replaces. If there is no path to this node, the fault must be discarded.
Thus, the query
operation contained in the
SparqlQuery
interface may return, in place of
the Out Message, the MalformedQuery
message, which is defined in this WSDL fragment
from sparql-protocol-query.wsdl:
<fault name="MalformedQuery" element="sl:faultDetails"></fault>
The SparqlQuery
interface operation query
described thus far is an abstract operation; it requires protocol
bindings to become a concretely invocable operation.
[WSDL2-Adjuncts] defines a means of binding abstract interface operations to HTTP. finish description of the HTTP bindings; give more example traces; sort out the way in which the service section of the normative WSDL will interact with the service section of actual deployments...
The following HTTP traces exemplify invocation of
the query
operation under several different
scenarios. examples normative or
descriptive?
This SPARQL query
PREFIX foaf: <http://xmlns.com/foaf/0.1/> 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://my.example/sparql/, as illustrated in this HTTP trace, which is formatted in order to be readable:
GET http://my.example/sparql/?query=PREFIX+foaf%3A+%3+Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E+ PREFIX+dc%3A++++++%3Chttp%3A%2F%2Fpurl.org%2+Fdc%2Felements%2F1.1%2F%3E+ SELECT+%3Fbook+%3Fwho+WHERE+%7B+%3Fbook+dc%3Acreator+%3Fwho++%7D &default-graph-uri=http%3A%2F%2Fmy.example%2Fbooks HTTP 1.0 Host: my.example User-agent: my-sparql-client/0.1 Accept: application/xml
That query against that 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/xml; charset=utf-8 <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2001/sw/DataAccess/rf1/result2"> <head> <variable name="book"/> <variable name="who"/> </head> <results> <result> <binding name="book"><uri>http://example.org/book/book2</uri></binding> <binding name="who"><bnode>r1115396427r1133</bnode></binding> </result> <result> <binding name="book"><uri>http://example.org/book/book3</uri></binding> <binding name="who"><bnode>r1115396427r1133</bnode></binding> </result> <result> <binding name="book"><uri>http://example.org/book/book1</uri></binding> <binding name="who"><literal>J.K. Rowling</literal></binding> </result> </results> </sparql>
This SPARQL query
PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> CONSTRUCT { _:somebody foaf:name ?who; foaf:made ?book } WHERE { ?book dc:creator ?who }
is conveyed to the SPARQL query service, http://my.example/sparql/, as illustrated in this HTTP trace, which is formatted in order to be readable:
GET http://my.example/sparql/?query=PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E+ PREFIX+dc%3A++++++%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E+CONSTRUCT+%7B_%3Asomebody+foaf%3Aname +%3Fwho%3B+foaf%3Amade+%3Fbook%7D+WHERE+%7B+%3Fbook+dc%3Acreator+%3Fwho+%7D &default-graph-uri=http%3A%2F%2Fmy.example%2Fbooks HTTP/1.0 Host: my.example User-agent: sparql-client/0.1 Accept: application/rdf+xml
That query against that 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:11 GMT Server: Apache/1.3.29 (Unix) PHP/4.3.4 DAV/1.0.3 Connection: close Content-Type: application/rdf+xml; charset=utf-8 <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns1="http://xmlns.com/foaf/0.1/"> <rdf:Description rdf:nodeID="r1_somebody"> <ns1:name rdf:nodeID="r1_r1115396427r563"/> </rdf:Description> <rdf:Description rdf:nodeID="r1_r1_somebody"> <ns1:made rdf:resource="http://example.org/book/book2"/> </rdf:Description> <rdf:Description rdf:nodeID="r2_r1_r1_somebody"> <ns1:name rdf:nodeID="r2_r1115396427r563"/> </rdf:Description> <rdf:Description rdf:nodeID="r2_r2_r1_r1_somebody"> <ns1:made rdf:resource="http://example.org/book/book3"/> </rdf:Description> <rdf:Description rdf:nodeID="r3_r2_r2_r1_r1_somebody"> <ns1:name>J.K. Rowling</ns1:name> </rdf:Description> <rdf:Description rdf:nodeID="r3_r3_r2_r2_r1_r1_somebody"> <ns1:made rdf:resource="http://example.org/book/book1"/> </rdf:Description> </rdf:RDF>
This SPARQL query
PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> ASK WHERE { ?book dc:creator ?who }
is conveyed to the SPARQL query service, http://my.example/sparql/, as illustrated in this HTTP trace, which is formatted in order to be readable:
GET http://my.example/sparql/?query=PREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E+ PREFIX+dc%3A++++++%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E+ASK+WHERE+%7B+%3Fbook+dc%3Acreator+%3Fwho+%7D &default-graph-uri=http%3A%2F%2Fmy.example%2Fbooks HTTP/1.0 Host: my.example User-agent: sparql-client/0.1 Accept: application/xml
That query against that RDF dataset, executed by that SPARQL query service, returns the following query result:
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/xml; charset=utf-8 <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2001/sw/DataAccess/rf1/result2"> <head></head> <results> <boolean>true</boolean> </results> </sparql>
Example forthcoming...
Example forthcoming...
Example forthcoming...
Example forthcoming...
As with any query protocol, RDF query services must take care that facts disclosed in or implied by query results do not violate applicable privacy or secrurity policies. Conversely, it is good practice to consider query interfaces when gathering data and to publish a realistic privacy policy for the benefit of everyone who contributes data.
It is impossible to identify every conceivable kind of private or sensitive information. However, addresses and credit card numbers are clearly sensitive, for example; and even the language constraints on literal queries can associate the client with a particular ethnic or language group. There is no a priori method of determining the sensitivity of any particular piece of information within the context of any given request. SPARQL query services should supply as much control over this information as possible to the provider of that information.
Query URLs and server logs contain information about clients' areas of interest. This information is clearly confidential unless otherwise indicated in a privacy policy. Storage and distribution of this data may be constrained by law in some countries.
Under-constrained queries can result in huge numbers of results and, thus, are one possible source of denial of service attacks. SPARQL query services may choose to detect under-constrained queries, impose time or memory limits on queries, or impose other restrictions to reduce the service's vulnerability to denial of service attacks.
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, and Dan Connolly. Thanks as well to my UMD colleagues Jim Hendler, Ron Alford, Yarden Katz, Chris Testa, and members of the Mindlab Semantic Web Undergraduate Social. I also thank Jacek Kopecky, Morten Frederiksen, Mark Baker, Jan Algermissen, Danny Ayers, Bernd Simon, Graham Klyne, Arjohn Kampman, Tim Berners-Lee, Dan Brickley.
CVS Change Log:
$Log: Overview.html,v $ Revision 1.24 2018/10/09 13:31:12 denis fix validation of xhtml documents Revision 1.23 2017/10/02 10:30:41 denis add fixup.js to old specs Revision 1.22 2005/05/28 02:06:09 eric use Ian's already published version Revision 1.18 2005/05/27 23:08:30 ijacobs removed links Revision 1.17 2005/05/27 23:03:31 ijacobs link fix Revision 1.16 2005/05/27 23:01:02 ijacobs anchor fixes? Revision 1.15 2005/05/27 22:57:29 ijacobs s/3/2 Revision 1.14 2005/05/27 22:55:15 ijacobs style fix Revision 1.13 2005/05/27 22:54:00 ijacobs add an id Revision 1.12 2005/05/27 22:52:59 ijacobs validity fixes Revision 1.11 2005/05/27 22:50:58 ijacobs wd link fix Revision 1.10 2005/05/27 22:46:38 ijacobs fixed per Kendall Clark instructions Revision 1.47 2005/05/23 17:30:20 connolly - WF fixes, including using valid names for reference ids Revision 1.46 2005/05/17 19:30:29 kclark *** empty log message *** Revision 1.45 2005/05/17 19:25:54 kclark *** empty log message *** 2005/05/17 19:20:13 kclark - tweaked "SPARQL query" and "SPARQL query string" bits - very tiny edits to policy/privacy section - added some new TODO marker text 2005/05/14 18:08:45 kclark Removed: - SparqlGraph - SparqlDiscovery - SparqlMaintenance - SparqlQueryX - Glossary - reference to SOAP stubs - XSLT stuff - SADDLE - MalformedRequest fault - SparqlX serialization format - WSDL 2.0 semantics appendix Added: - example SELECT trace - example CONSTRUCT trace - example ASK trace