SparqlXmpp

From W3C Wiki

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.

Example IQ Trace

<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>


NOTE: The sparql namespace given above is old, and should be as follows to match the latest results working draft -- Dave Beckett

<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
...