Permission to break feature freeze for Nepomuk and Soprano

Richard Dale richard_dale at tipitina.demon.co.uk
Mon Sep 3 18:39:32 BST 2007


On Monday 03 September 2007, Sebastian TrĂ¼g wrote:
> BTW: The Jabber thing sounds very interesting and very close to what is
> done in the Nepomuk project. Would you be interested in talking about the
> ideas with some of the Nepomuk guys who do the same for the Nepomuk Java
> prototype?
Yes, do they have a mailing list? I read about the DBin project on the nepomuk 
site, and I thought it would be better off if it used jabber/XMPP as a 
transport, rather than building their own. So I tried an experiment to send a 
SPARQL query over xmpp in ruby and it came out really well - there is a 
perfect match - you just use IQ message types. But when I wanted to try 
querying the nepomuk data store that's when I found you couldn't get the 
results in xml/sparql format which i needed to be able to send back to the 
other jabber client.

This is what the code looks like:

------------------------------------------------------------------------------------------
# SPARQL query from a jabber client:

    # Create an 'IQ' message
    def sparql_query(jid, text)
      msg = Jabber::Iq.new(:get, jid)
      @@iq_query_id += 1
      msg.id = @@iq_query_id
      query = IqQuery::new
      query.add_namespace("http://www.w3.org/2005/09/xmpp-sparql-binding")
      query.add_text(text)
      msg.add(query)
      puts msg.to_s
      send!(msg)
      return msg.id
    end
...
im = Jabber::Simple.new('admin at mardigras/sparqlclient','yyyy')
msg_id = im.sparql_query('rdale at mardigras/sparqlserver', 
                         "PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
SELECT DISTINCT ?o WHERE {?s foaf:name ?o.}")
im.disconnect

------------------------------------------------------------------------------------------
# Replying to the SPARQL query:

SPARQL_RESULTS = <<-EOS
<sparql xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema#" 
        xmlns="http://www.w3.org/2005/sparql-results#">
  <head>
    <variable name="o"/>
  </head>
  <results>
    <result>
      <binding name="o">
        <literal>Libby Miller</literal>
      </binding>
    </result>
    <result>
      <binding name="o">
        <literal>Tim Berners-Lee</literal>
      </binding>
    </result>
<!-- ... more bindings here -->
  </results>
</sparql>
EOS

im = Jabber::Simple.new('rdale at mardigras/sparqlserver','xxxx')
messages = im.iq_messages
msg = messages[0]
doc = REXML::Document.new SPARQL_RESULTS
im.sparql_results(msg.from.to_s, msg.id, doc)
im.disconnect

-- Richard




More information about the kde-core-devel mailing list