SPARQL XMPP Communications
Introduction
XMPP, the protocol behind the more commonly known Jabber chat services, is an XML based communications format with significant support for extensibility. This messaging framework makes for an ideal method of transportation of SPARQL queries to various endpoints, querying the RDF data stored at those endpoints using SPARQL and receving data in the standardized SPARQL XML query results format.
Why SPARQL?
SPARQL is the W3C's standardized language for querying RDF datastores. It is implemented in a number of libraries in several different programming languages, and is on the track to become a W3C Recommendation in the near future. (As of this writing, the period for Last Call comments had recently closed.) This specification is the single most commonly supported query language, and offers a wide range of features not supported by query languages.
SPARQL features a similarly specified XML results format - the only such format in existance. Given XMPP's basis in XML, this is a powerful feature, and one of the primary reasons that SPARQL and XMPP seem so well suited for one another. SPARQL's results format will allow clients to receive standardized results from servers regardless of implementation on the server side of SPARQL results.
Why XMPP?
The extensible and open Jabber protocol is the only existing instant messaging protocol which is defined and specified via the IETF standards board. Most other communications protocols are proprietary, and difficult to use, or designed specifically for one purpose, making other uses difficult. Microsoft Messenger and Yahoo both fall into the former: the protocols are controlled by those bodies specifically, and have frequently been changed in order to prevent third party developers from interacting with those services. AIM is an example of a well defined protocol which is difficult to implement and limited in scope. In comparison, the world of XMPP seems quite rosy: an XML based format with seperate blocks for sending messages, presence information, and additional user-defined packets.
The Info/Query (IQ) packet type are the ideal candidate for extension and use in a SPARQL/XMPP environment, given that they are designed to get information from the server. By setting up a specific SPARQL endpoint for these queries, it is possible to have queries directed to a SPARQL server seperate from the user's main client with no detrimental effect to the user. This type of interaction -- queries specifically directed at a seperate endpoint than the main client -- are another benefit of the Jabber protocol which other protocols do not provide.
The Format
To create a client or endpoint which supports queries via SPARQL, your client will need to accept IQ queries of type "get", which arrive with the namespace http://www.w3.org/2005/09/xmpp-sparql-binding. The Query Node MUST contain two elements:
- meta: This element is reserved for information about the query. Currently, there are no attributes defined for this element: It is put in place for further development. Implementations MAY include attributes in this element which are not defined by the W3C SPARQL XMPP binding: these attributes should be proceeded by an "x-". However, any attributes which are not implementation specific should proceed with registration as quickly as possible, so as not to create widespread use of unregistered attributes.
- sparql: This element is the full resultset of the SPARQL query. It is presented in the format described by SPARQL Query Results XML Format.
The SPARQL server endpoint should reply with an IQ packet with a matching ID to the incoming IQ packet. The return IQ packet should be of type "result". An example communication might look something like:
<iq to='crschmidt@crschmidt.net/sparql' type='get' id='2'> <query xmlns='http://www.w3.org/2005/09/xmpp-sparql-binding'> SELECT ?a WHERE { ?a &http://xmlns.com/foaf/0.1/nick> "crschmidt". } </query> </iq> <iq to='crschmidt@crschmidt.net/sparql' type='result' id='2' from='crschmidt@crschmidt.net/sparql'> <query xmlns='http://www.w3.org/2005/09/xmpp-sparql-binding'> <meta /> <sparql xmlns='http://www.w3.org/2001/sw/DataAccess/rf1/result'> <head> <variable name='a'/> </head> <results> <result> <a uri='http://crschmidt.net/foaf.rdf#crschmidt'/> </result> <result> <a bnodeid='r1124565507r58'/> </result> <result> <a bnodeid='r1125462262r174'/> </result> </results> </sparql></query></iq>
Existing Implementations
This protocol is under development using a number of different environments and tools from a variety of developers. This page seeks to provide the best possible information on the current status of these implementations.
- SparqlXMPP Python -- Using the jabberpy jabber library, this client/server written in Python uses Redland for RDF processing and storage, and is the original implementation of this protocol to the best of the author's knowledge.