Fun with connection properties

How to connect to MySQL over JDBC:

jdbc:mysql://localhost/mydb?paranoid=true
      &pedantic=true&ultraDevHack=true

Surprisingly, neither pessimistic=true nor patronizing=true work.

(MySQL JDBC documentation)

Posted in General | Comments Off on Fun with connection properties

A Friendlier RDF API for Java

Back in January 2005, being annoyed with the verboseness of a certain RDF API for Java, I tried to come up with a friendlier way of manipulating generic RDF from Java. My experiments never went anywhere and I forgot about it after a few days. I just found the files on my hard disk and think this snippet is worth sharing:

public void testCreatePPD() {
    Document profile = RDF.newDocument();
    Resource richard = RDF.resource();
    Resource homepage = RDF.URI("http://richard.cyganiak.de/");
    profile.assert(profile, "rdf:type",
            "foaf:personalProfileDocument");
    profile.assert(profile, "foaf:primaryTopic",
            richard);
    profile.assert(richard, "foaf:name",
            RDF.literal("Richard Cyganiak"));
    profile.assert(richard, "foaf:mbox",
            RDF.URI("mailto:richard@cyganiak.de"));
    profile.assert(richard, "foaf:homepage",
            homepage);
    profile.assert(homepage, "dc:title",
            RDF.literal("Richard Cyganiak's Homepage"));
    profile.assert(homepage, "dc:description",
            RDF.literal("Meine Homepage (deutschsprachig)", "de"));

    ResourceSet people = profile.getAll("foaf:Person");
    Iterator it = people.iterator();
    while (it.hasNext()) {
    Resource person = (Resource) it.next();
        String name = profile.get(person, "foaf:name").asString();
        System.out.println(name);
    }
}

That looks pretty nice, I think. Wrapping Jena’s Graph interface into such a developer-friendly API wouldn’t be all that hard.

Of course, compared to ActiveRDF that code still looks as unfun as having your teeth pulled.

Posted in General, Semantic Web | Comments Off on A Friendlier RDF API for Java

RDF/JSON

RDF/XML sucks: People loudly complain about RDF/XML, the standard serialization format of RDF graphs into XML. It’s crufty, it’s buggy, it misses the point, it’s a royal pain. Turtle/N3 is better for reading and writing by humans, but writing a parser is still a lot of work. A number of simpler XML alternatives have been proposed, e.g. TriX and RPV and RXR, but neither has gained major support.

The Serializing SPARQL Results as JSON note shows how to represent SPARQL SELECT results – which are normally XML files – as JSON structures. That’s great for doing AJAXy stuff. It’s supported in a number of SPARQL engines, such as Joseki, ARC, Redland/Rasqual and D2R Server. There’s a Javascript library for client-side processing. Working with it is fast, efficient and fun.

RDF/JSON: Now this is kind of obvious: You can use SPARQL/JSON to serialize RDF graphs. A table with three columns, s, p, o, with each row being one RDF triple.

<http://richard.cyganiak.de/foaf.rdf#cygri> rdf:type foaf:Person;
    foaf:name "Richard Cyganiak";
    foaf:mbox <mailto:richard@cyganiak.de>;
    .

This simple graph serializes to:

{
  "head": {
    "vars": [ "s" , "p" , "o" ]
  } ,
  "results": {
    "distinct": false ,
    "ordered": false ,
    "bindings": [
      {
        "s": { "type": "uri" , "value": "http://richard.cyganiak.de/foaf.rdf#cygri" } ,
        "p": { "type": "uri" , "value": "http://www.w3. org/1999/02/22-rdf-syntax-ns#type" } ,
        "o": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/Person" }
      } ,
      {
        "s": { "type": "uri" , "value": "http://richard.cyganiak.de/foaf.rdf#cygri" } ,
        "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/name" } ,
        "o": { "type": "literal" , "value": "Richard Cyganiak" }
      } ,
      {
        "s": { "type": "uri" , "value": "http://richard.cyganiak.de/foaf.rdf#cygri" } ,
        "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/mbox" } ,
        "o": { "type": "uri" , "value": "mailto:richard@cyganiak.de" }
      }
    ]
  }
}

Here’s my entire FOAF file in RDF/JSON.

Emitting RDF/JSON: Every JSON-capable SPARQL processor will emit this serialization by answering this query:

SELECT ?s ?p ?o WHERE { ?s ?p ?o }

Simple.

Consuming RDF/JSON: It’s trivial from Javascript, and there’s JSON parsers for just about any language under the sun.

Do we need this? I think it’s useful. Javascript is the duct tape of Web 2.0, and a simple and convenient method of consuming and producing RDF from Javascript will be important.

Wishlist:

  • JSON support in all SPARQL endpoints (please please please!)
  • An online service that transforms RDF/XML and Turtle to RDF/JSON
  • A simple Javascript library that implements find(s/p/o) on RDF/JSON models
  • A convention for putting namespace prefix declarations and the base URI into RDF/JSON.

(This post was triggered by this thread, started by Björn Thalheim, on jena-dev. Update: Björn has code for turning Jena models into RDF/JSON and back.)

Posted in General, Semantic Web | 1 Comment

SPARQL developers discussion mailing list

The W3C’s public-sparql-dev mailing list is a bit underpublished (or rather, it’s in an abandoned cellar behind a cabinet with a sign reading “beware the tiger”). Nonetheless, it is the place where to discuss implementation and usage of W3C’s new RDF query language. Let the flaming begin!

Posted in General, Semantic Web | Comments Off on SPARQL developers discussion mailing list

This blog doesn’t have enough cat photos

Hats off to anyone who can watch this without laughing!

Bonus link.

Posted in General | Comments Off on This blog doesn’t have enough cat photos

WWW2006 wrapup

Wow, what a week!

WWW: This is a fantastic conference, very high quality, excellent organisation, lots and lots of fascinating people.

Edinburgh: The label “Athens of the North” is appropriate. It’s all there, the city sprawling over several hills, the mountain backdrop, the sea in the distance, the withering stone monuments. Just replace the light browns and yellows and greys of Greece with the saturated greens and wet sandstone colors of Scotland and set it against a grey sky of low-hanging clouds. Edinburgh is the only city I know that actually looks better in rain. I’ll visit again.

The Semantic Web: I’m frequently voicing my frustrations with RDF, but seeing all the energy at WWW I can’t help but think that we’re on track. People have tried out lots of things, and a consensus is emerging on what works and what doesn’t. The big IT companies start to throw resources at RDF, “because customers ask for it and we want to make money,” as Susie Stephens from Oracle said in her talk.

Tim Berners-Lee: He’s a visionary, and seeing him in person is great. I’ve read his book recently, and after his keynote appearances, his comments in workshop and demo sessions, and his own demo of Tabulator, I think I begin to understand what he wants the Semantic Web to be. His vision is surprisingly different from what most of the community is doing. I’ll expand on this in a future post.

Web 2.0: The new version is no longer in beta, it’s stable and deployed, sites are switching over one by one, and the big players depend on it for their business-critical stuff. If you’re in web development and don’t live and breath AJAX and JSON and RESTful APIs yet, be worried.

JSON: “Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” (Antoine de Saint-Exupery.) JSON over REST is web service perfection. Javascript is the duct tape of Web 2.0.

RDFa: The new method of embedding RDF in HTML received a warm reception. It’s a very leightweight method of publishing RDF and not all that much more complicated than the popular microformats approach. I think it was Carole Goble who remarked that W3C should have started out with RDFa, instead of pushing RDF/XML.

SPARQL: SPARQL feels almost a bit over-hyped. It was certainly much talked about. I wonder when companies will start to advertise their “enterprise-class SPARQL solutions.” I expect it to become a buzzword over the next year. SPARQL will drive RDF’s adoption in the data integration area, but won’t have much effect on the “public” Semantic Web.

Semantic MediaWiki: TimBL is a fan. So am I. This is how you integrate things learned from RDF into existing software in an unobstrusive and useful way.

D2R Server: My demo was pretty average I think; my time was cut short because I had the day’s last slot, and (as always) I should have rehearsed more. I’ve got a lot of good feedback though and have a very clear picture of where I want to take the tool. The database-to-RDF area will be quite important, and I think we already have got a lot of things right.

Great conference, highly recommended for anyone interested in the future of the Web. WWW2007 is in Banff, Canada. I will try hard to be there.

Posted in General, Semantic Web | Comments Off on WWW2006 wrapup

Off to Edinburgh

WWW2006 is starting tomorrow. I will be giving a demo of D2R Server on Thursday.

To save money, I’m flying to Glasgow and take the train from there. Edinburgh is a beautiful city I hear. This is the first time I attend such a major conference. I’m looking forward to an enjoyable and interesting week.

Posted in General, Semantic Web | Comments Off on Off to Edinburgh

Backlog

Greg Knauss:

My entire life has devolved into an endless, grinding slog through my back-log. Everything I do is about catching up, doing the stuff I didn’t get done the day before, plowing through some other goddamned thing that needs my attention. Ending the day without actually adding to the total aggregate is a victory. There are times when it piles up faster than I can shovel it away.

I so know what he means.

(via Fred Wilson)

Posted in General | Comments Off on Backlog

Achilles is dead

The Under Odysseus blog, a serialized retelling of the siege of Troy through the eyes of Eurylochus, an officer with administrative duties in Odysseus’ entourage, is one of my favourite sources of light entertainment these days. The story reaches a climax today with the Achaean champion being murdered while he and other nobles offer birthday presents to the besieged city’s king.

Damn, this is what RSS was invented for.

Posted in General | Comments Off on Achilles is dead

Semantic MediaWiki inline queries

New in Semantic MediaWiki 0.4: inline queries.

Syntax is quite simple and fits in well with other MediaWiki idioms. The queries produce comma-separated lists, bullet lists, or tables. Expressivity seems to be comparable with RDQL plus sort and limit. No optional patterns though, which sucks for tables.

The lists on this page are auto-generated by inline queries.

A cool use: Embed inline queries into text to avoid duplicated information:

The head of chain of command is the President of the United States,
currently [[United States]] [[Head of state::*]].

This will currently produce “George W. Bush,” but will update to “Joseph Biden” as soon as someone updates the United States article after the next election (if we are to believe Scott Adams).

Anybody else wishing for the day where we can embed inline queries into any HTML page?

Posted in General, Semantic Web | Comments Off on Semantic MediaWiki inline queries