Got RDF?

2005-08-30

Chatting with Dan Brickley just now, he mentioned that he's interested in sending SPARQL over XMPP so that folks can query things like each other's local RDF databases for information about photos, calendar events, tunes, etc. Here's how I think we'd do it (using examples similar to those at Dave Beckett's demo page):

  1. First, find out the resource of the SPARQL-aware script on the other side. Your script can get presence from all of your friend's XMPP resources and then send a Service Discovery query to each one in order to figure out which one supports our little custom namespace (or of course you can cache that info using Entity Capabilities). Here we'll assume that each side has done the necessary discovery and we have two SPARQL-aware resources: stpeter@jabber.org/sparql and danbri@jabber.org/rdfdb (no need to settle on conventional resource names since we have service discovery).

  2. Dan wants to know the Jabber IDs of the people in my FOAF file, so he sends me an IQ-get that looks something like this (the xmlns is just a placeholder for now, note that we have to escape angle brackets in the SPARQL query):

    <iq type='get'
           from='danbri@jabber.org/rdfdb'
           to='stpeter@jabber.org/sparql'
           id='sparkling1'>
    <query xmlns='http://www.w3.org/TR/rdf-sparql-query/'>
          PREFIX foaf: <http://xmlns.com/foaf/0.1/>
          SELECT ?jabberID
          WHERE {
                 ?x rdf:type foaf:Person .
                 ?x foaf:name ?jabberID
          }
    </query>
    </iq>
            
  3. Now my SPARQL-aware script returns an IQ-result using the SPARQL Query Results XML Format:

    <iq type='result'
           from='stpeter@jabber.org/sparql'
           to='danbri@jabber.org/rdfdb'
           id='sparkling1'>
      <sparql xmlns='http://www.w3.org/2005/sparql-results#'>
        <head>
          <variable name='jabberID'>
        </head>
        <results ordered="false" distinct="false">
          <result>
            <binding name='jabberID'>
              <uri>xmpp:dizzyd@jabber.org</uri>
            </binding>
          </result>
          <result>
            <binding name='jabberID'>
              <uri>xmpp:jer@jabber.org</uri>
            </binding>
          </result>
          <result>
            <binding name='jabberID'>
              <uri>xmpp:pgmillard@jabber.org</uri>
            </binding>
          </result>
        </results>
      </sparql>
    </iq>
            

That's a first pass, anyway. Further experimentation probably necessary.


Peter Saint-Andre > Journal