gnowsis and AJAX: running SERQL queries with XML/RPC

Gnowsis rocks so hard that the neighbours complain. read on to know why:

(also available at this wiki page)

XML-RPC developing with gnowsis

Yes, we have AJAX, and we love it. You can call many services of gnowsis using XML/RPC. The nice thing about this approach is, that every object that is defined as API of gnowsis inside a service.xml file is automatically hosted as XML/RPC server. A small example to show what you can do when calling the TaggingApi:

// Example: call method getPossibleTagsForTagName of API 'tagging' on service 'gnowsis-server'
// (include gnowsis.js and jsolait dependencies)

// call method
var tags = gnowsis_callXmlMethod("gnowsis-server", "tagging", "getPossibleTagsForTagName", rlabel);
// result is an array of maps
for (var i = 0; i < tags .length; i++)
  // tag is a map, an array with named index.
  var tag = tags[i];
  // read uri and name of result
  var tagUri = tag["uri"];
  var tagName = tag["name"];
  alert("hey, I found "+tagName+" ("+tagUri+")");

What happens in this script?

First the dependencies: to make this run, include the gnowsis.js dependencies. If you run gnowsis, go to for an example.

// (include dependencies)
<script type='text/javascript' src='web/jsolait/init.js'></script>
<script type='text/javascript' src='web/jsolait/lib/urllib.js'></script>

<script type='text/javascript' src='web/jsolait/lib/xml.js'></script>
<script type='text/javascript' src='web/jsolait/lib/xmlrpc.js'></script>
<script type='text/javascript' src='gnowsis.js'></script>

When you have done that, the gnowsis_callXmlMethod() function is available. You can test that by calling something simple as this:

// show the uri of the current user.

We called a method to get tags with a certain name in it. The gnowsis_callXmlMethod() method takes three (or more) parameters. The result value is an XML/RPC result. If you want to know what is possible in XML/RPC see at the bottom for the external links. The result value is, in this case, an array containing named arrays (maps).

var tags = gnowsis_callXmlMethod("gnowsis-server", "tagging", "getPossibleTagsForTagName", rlabel);

Note that when the server throws an exception, the exception message will be passed to the xml/rpc client, so you know whats happening when it fails.

The real rocking cool example

Download gnowsis and run this page:

using only these lines of code:

function runSerqlExample()
   // turn debug alerts off
   gnowsis_showdebugalert = false;
   var formC = document.forms["formserqlexample"];
   var queryString = formC.elements["rquery"].value;  
   try  {
	   var res = gnowsis_callXmlMethod("gnowsis-server", "dataaccess", "querySelect", 
    	  queryString, "serql");
   } catch (e)
     alert("error querying: "+e);

 * render the serql query result.
 * query result is a vector of hashmaps, pretty easy.
function renderSerqlExample(res)
   gnowsis_debug("rendering table");
   var render = "<table>";
   for (var i = 0; i < res.length; i++)
      var row = res[i];
      // render header?
      if (i==0)
		for (col in row)
          render += "<td>"+col+"</td>";   
        render += "</tr>";
      // render row
      for (col in row)
        render += "<td>"+row[col]+"</td>";  
      render += "</tr>";
   render += "</table>";
   var exampleOut = document.getElementById('SerqlExampleoutput');
   exampleOut.innerHTML = render;

yes, you want to dig this?

So what services can I call?

You can call all services that are listed in the corresponding service.xml files.
We encourage you to look at this service first:

  • TaggingApi, you can call the methods defined in the TaggingApi – Javadoc
  • PimoStorage, you can add/remove triples from the pimo via this api.
  • every gnowsis-server API that is listed.
  • note that you can only call methods that have really simple input/output values. Not every method is allowed for XML/RPC access, we are currently working on making more methods available. Only methods with the following datatypes as input/output work:
    • no void result supported (XML/RPC standard)
    • Integer, Boolean, String, Double, javaa.util.Calendar, java.util.Date, byte[], java.util.Map, java.util.List
    • no more. espacially this will not work: com.hp.hpl.jena.rdf.model.Resource !
    • we are working on providing String-based interfaces for most of our methods.

And what about Mozilla and XUL?

Now comes the tricky part: You want to write an XPI plugin for Mozilla Firefox or Mozilla Thunderbird and access the nice sesame repository of gnowsis. That is possible, but it needs an adapted version of the jsolait library and it is easier to copy/paste our working prototype than to hack something from scratch.

So, all Mozilla fanatics that want to SPARQL from out there, please look at the code of this SVN project:

All you have to do is copy/paste the whole project, change some parameters, run the build.xml and you have a plugin for Thunderbird 1.5.

Ok, I want to do AJAX with gnowsis, what to do?

So the first thing you have to do, is run through the usual GnowsisDevelopingBeta. Then, you have a running gnowsis server with all the XML/RPC services available on localhost:9993.

The best way to use gnowsis XML/RPC and AJAX services is, at the moment, to edit the HTML files in /services/gnowsis-server/*.html. They form a nice basis to get started, we frequently enlarge them with more examples. You can also start any other HTML project on your harddisk, Javascript and JSOLAIT are rock-hard technology and run pretty easy.

Restrictions and caveats

No real ajax library used yet. Did you notice? we did not use coldfusion or any other cool Ajax library. We will, surely, soon do that.

Be aware that our server only answers to requests coming from So, you will not be able to run server-to-server programs with it. That is good that way: gnowsis is a desktop server, not a web server. If you feel to change that, you may want to look at that jetty.xml file closer, but be warned: opening gnowsis to the network is not just a small security risk, its really a problem. Don’t open the gnowsis ports to outside, people can easily run shell commands via the XML/RPC port with your user’s rights and cause havoc on your machine.


Apache XML/RPC doc

Dynamic HTML and XML: The XMLHttpRequest Object

flashmob tanzen in Kaiserslautern

link to website

Kaiserslautern: Tanz in den Mai FlashMob in Kaiserslautern
Na, das könnte ein spannendes Experiment werden. Der FlashMob trifft sich Freitag, 28. April 2006 in der Innenstadt, Kreuzung der Fußgängerzonen Fackelstraße/Kerststraße (beim H&M / P&C).

Zeit: exakt 18.30 Uhr


– Es finden sich Paare, die auf dem Platz tanzen. (Ich kann auch nicht tanzen, also halb so wild.)
– Leute, die keinen Partner haben, können mit einer irgendwo gemoppsten Blume auf Damen, oder Herrenjagd gehen. (Blume = Erkennungszeichen)
– optional kann man statt tanzen auch sich umarmen oder küssen
– Der FlashMob endet genau um 18.35 Uhr

– Der FlashMob lößt sich nach der Aktion in alle Richtungen auf
– Weder vor oder nach der Aktion sind Grüppchenbildungen erlaubt (ausser den Paaren)
– Nur Mitmachen ist erlaubt. Erscheinen und zuguggen verboten.

Simple, XSLT friendly RDF/XML

We need a simple RDF/XML serialization for XSLT transformations. I wrote my ideas about this here:


Using the general RDF/XML spec, the RDF serialization can look quite different depending on rdf-writer implementation. These diversity in writing RDF makes writing XSLT transformation a black art. What happens is that the data shows up in so many different ways, that many people write big hacks to get it work.

Solution: a simple RDF/XML syntax that is RDF/XML compatible but has some restrictions to it. It is kind-of deterministic and can be better parsed in XSLT. I [LeoS] call it SimpleRdfXml.

See Also


This is a fragment of FOAF, using the simpleRDF/XML


    xmlns:dc="" >
  <rdf:Description rdf:about="">
    <rdf:type rdf:resource=""/>

    <rdfs:comment>The first name of a person.</rdfs:comment>
    <rdf:type rdf:resource=""/>

    <rdfs:domain rdf:resource=""/>
    <rdfs:range rdf:resource=""/>
    <rdfs:isDefinedBy rdf:resource=""/>

Design Rules of SimpleRdfXml

  1. be compatible with RDF/XML

  2. but only a subset

  3. restrict stuff to simplicity


  1. no nested stuff

  2. all literals as <foaf:name>Hello!</foaf:name> and not attributes like <blub foaf:name="Hello!">

  3. no blank nodes (replace them wirth random uris while serializing)

  4. serious: no blank nodes. They force you to check all the time for different ways to lookup resources.

  5. only full uris, no relative ones

  6. type always as triple, not in xml


Using Jena, the easiest way to get it is:

simple rdf:
Model m = ...;
m.write(System.out, "RDF/XML");

bad rdf:
m.write(System.out, "RDF/XML-ABBREV");

more detail

No nested stuff

All literals as elements, not attributes

Querying from XSLT is easy with both, but having to check both all the time sucks. Most hackers go with the element solution, as it can contain datatypes and languages and can have better strings with CDATA elements.

No blank nodes

Thats hard to achieve. The idea behind is to easily query other nodes and follow links, when blank nodes are in game, this is harder.


In foaf-vocab, there is a uri called “../sig” which is the show-stopper. don’t do it

Type always as triple

Wrong: <foaf:Person rdf:about="urn:example"> Right:

<rdf:Description rdf:about="urn:example"> 

  <rdf:type rdf:resource=""/>

When things have two types, this comes in handy. Again, a step for making it simpler.


This RDF is BAD RDF and is not simple, it breaks the rules: nono:

<foaf:Person rdfs:label="blub">
  <rdf:hasblub >


SimpleRdfXml (zuletzt geändert am 2006-04-24 18:16:00 durch LeoS)

Nepomuk meeting in Paris

Wednesday and thursday we had a smaller Nepomuk meeting in Paris to synchronise the Semantic Desktop backbone architecture with the plans of some Nepomuk Partners. Thomas Roth-Berfghofer and myself went to see Mikhail Kotelnikov, Alexander Polonsky, and Stéphane Laurière. The first two are from cognium systems and are working on a software to support bioscientists with Semantic Desktop technology, the latter is working for Edge-IT, who provide services to the Mandriva Linux community (the mandriva club).

Meeting was very productive, getting practitioners and scientists together to see how the Semantic Desktop can help people at large. Photos of the meeting are here:

Looking forward to our upcoming Semantic Desktop hack next week and the big Nepomuk Meeting at the beginning of may, people come together now on Semantic Web.

flashmob kissenschlacht

Nehmt ein kissen mit und dann gibt kissenschlacht. Heute so geschehen in Kaiserslautern, 13:30.

fazit: überraschend doch viele leute, guter kampf. Auch gut: ein klares Ende, durch eine Trillerpfeife eingeläutet. Viel spaß, interaktive spiele wie “gruppe a gegen gruppe b”, geworfene und geschwungene Kissen.

Videos bei vimeo und youtube (bei vimeo kann man runterladen)


und photos bei flickr in der group , tag kaiserslautern

(sorry, flickr badge javascript geht hier nicht)

photos in pillowfight tagged with kaiserslautern More photos in pillowfight tagged with kaiserslautern