Categories
People

Morning ritual

I love to get up early in the morning and sit at my desk and watch the morning ritual unfold. From my window on the second floor I can see the entire neighborhood, watch the people go about their lives.

Every morning, between 8 and 8:30, an elderly couple take their morning walk, he in the same lightweight gray suit, she in layers of bright colorful wrappings; he in the lead, she always walking at least four feet back. Always crossing the road in the exact same spot, never speaking.

He wore a hat at first but lately has been going bare headed. She would hold her outer robe between her teeth to hide her lower face, but lately she’s allowed her face to show, though her head is always covered — bright pink and green. Perhaps its my imagination, but it seems as if the distance between them is growing less, ever so slightly, by inches.

Yesterday, I was astonished when at the corner, he turned around and spoke to his wife. At that moment, they were almost side by side. As if aware of this unseemly display of public affection, they widened the distance between themselves, and she adjusted the covering on her head to make sure no hair was showing.

I wonder if he’ll be wearing a hat again today?

Categories
RDF

The RDF Query-O-Matic

Recovered from the Wayback Machine.

Note that my current server does not support Tomcat-based application. The Java-based Query-o-Matic is disabled until I can move it to the appropriate environment.

I created a small application, the RDF Query-o-Matic, using Java and HP’s Jena (a Java RDF API), and hosted it on my Tomcat server. The Query-o-Matic accepts the name of an RDF file (any valid RDF file), and an RDFQL (RDF Query Language) query, and will print out a test value found as a result of that query. I created the tool as a way of testing queries without having to go back into my code as I work.

You don’t have to be a techie, or a programmer, or familiar with RDF or even XML to work with RDFQL, as the Query-o-Matic will demonstrate. All you need is a bit of logic, and a familiarity with old nursery rhymes.

Taking it one step at a time…

RDF is a meta-model of information, similar to the relational data model. RDF/XML is a way of serializing the model information, as one would use a relational database to store relational data. Carrying the analogy to its natural conclusion, as SQL is to relational data, RDFQL is to RDF data.

RDFQL is actually not that complex. The key is remembering that every ’statement’ in an RDF file is made up of a subject, predicate (property), and value. If you view Mark Pilgrim’s FOAF file in graphical format, using the RDF Validator (access here), the predicate (property) always appears on an arc – the subject is to the left of the arc and the value of the predicate, the object, is to the right. Every RDF statement can be broken down into one of these <subject, predicate, object> triples.

RDF queries are nothing more than patterns based on this triple. This might sound confusing, but not if you take the queries one step at a time.

For instance, if I want to access and print out all of the NAME elements in Mark Pilgrim’s FOAF file, I would use a query like the following:

select ?name where (?subject, <http://xmlns.com/foaf/0.1/name>, ?name)

In this query, the SELECT clause (’select ?name’) references the variable I’ll access from the results; the rest of the query, the WHERE clause has the actual query. In this instance, I don’t care what the subject is so I’m using a placeholder ?subject that’s basically ignored. It’s followed by the predicate that forms the query, in this case the NAME. Since all elements in RDF belong to a namespace, I’m preceding the element with its namespace, and including the whole within angle brackets.

The angle brackets are used to destinguish an element from a literal value

Following the predicate is another placeholder, this one for the name element’s value (i.e. the actual names).

The whole is entered into the Query-o-matic as follows:

URL: http://www.diveintomark.org/public/foaf.rdf

query: select ?name where (?subject, <http://xmlns.com/foaf/0.1/name>, ?name)

value to print: name

View the result.

Let’s say I want to refine the query – I only want the value of ‘name’ for the subject f8dy. I would then need to modify the query to add the subject as well as the predicate:

URL: http://www.diveintomark.org/public/foaf.rdf

query: select ?name where (<http://www.diveintomark.org/public/foaf.rdf#f8dy>, <http://xmlns.com/foaf/0.1/name>, ?name)

value to print: name

This time only one value is returned (if Mark’s RDF file doesn’t change), Mark Pilgrim.

Well, this is great for finding all elements of a certain type of if you’re accessing a specific statement given a subject. but what if you want to find all elements of a certain type that have a specific relationship with another element? After all, the power of RDF is the ability to record statements and relate these same statements to one another.

Piece of cake. All you have to remember is an old, old nursery rhyme:

The itsy bitsy spider
Crawled up the water spout
Down came the rain
And washed the spider out
Out came the sun
And dried up all the rain
And the itsy bitsy spider
Crawled up the spout again

If you sang this as a kid (or sing this song with your own kids), you would play out the motion of the spider climbing by placing your hands together, the small finger of your right hand against the thumb of your left, and the small finger of your left against the right thumb. As you sing the song, you twist your hands, keeping the top two digits in contact, bringing up the bottom in a circular motion, re-joining these digits at the top. You would repeat this action, twisting on the top digits, bringing up the bottom and so on, never breaking the contact between the two hands.

The objective with your hands during this song was to always keep contact between the two and still have motion. That’s the basic foundation of more complex queries in RDFQL: mapping one element of one triple, to another element on another triple in a chained path that eventually gets you from point A all the way to point Z.

As an example, within Mark’s FOAF file, he has listed a group of people that he ‘knows’, each of whom has a NAME. To print out just the names of these people, we’ll need to adjust the query to find each statement that has ‘know’ as predicate, and then use the object of that statement, as the subject of the next triple. This gets us a list of people who Mark knows. To get their actual names, the NAME element is then used in the predicate of the second triple, to refine the result.

Well, this one definitely needs an example:

url: http://www.diveintomark.org/public/foaf.rdf

query: select ?name where
(?a, <http://xmlns.com/foaf/0.1/knows>, ?object),
(?object, <http://xmlns.com/foaf/0.1/name>, ?name)

print: name

In this, the first triple returns statements where the predicate is the ‘knows’ element – all known people. The results of this triple are then passed to the next. In the second triple, the object of the first triple – the identifier as it were of the individual people, is the subject of the new triple. This will return all of the properties for each of the known people. Since we’re only interested in the ‘name’ property, we further refine the query to only return the name values, which are printed out.

Check out the results.

The key to this query working is that not all objects (property values) are literal values – sometimes they can be subjects, too, as occurs with the ‘knows’ relationship in FOAF. These objects can then be plugged in as the subject of a new query (note the highlighted ?object), and the results combined to return not only ‘names’ of people, but names of people that Mark knows.

Just like walking that spider up the wall.

Of course, not all queries are going to be as straight forward as they are in the FOAF example, and the next installment on RDFQL will take a look at additional and increasingly complex examples. In addition, the Tomcat/Java Query-o-Matic will be joined by its PHP cousin: Query-o-matic Light.

Categories
Weblogging

Pilgrim’s rock

One year ago today, Mark Pilgrim set a dangerous precedent: when told by his boss to remove his weblog or else he would lose his job, he said no, and was fired. Defying management was bad enough, but to make matters worse, since that fateful day Mark has enjoyed success after success — a better job, respect and success online, even getting engaged.

Mark, that’s not how these things are supposed to happen. When management gives you an order, you’re supposed to grovel; and if you don’t and get fired, you’re supposed to end up on the street, destitute, homeless, begging lattes on the street corner.

Next thing you know, with the example you set, all workers are going to want to be treated with dignity and respect. Sheesh!

You’re a dangerous man, Mark. And only your kitty and I and every corporate manager in America knows it.

Categories
Critters Technology

Cats and computers

I’ve been having considerable problems with my Dell laptop keyboard. Several of the keys (SHFT, CTRL, and ‘c’) only work if you pound them, hard, and the ‘a’ key keeps repeaaaaaaaaaaating.

Thinking that the keyboard needed cleaning, I grabbed an index card and started digging around underneath the keys.

Cat hairs. Thousands and thousands of cat hairs. Underneath every key is a little wad of silvery fur. Even after I removed about a cat’s worth of fur, I still had to pound the ‘c’, and the ‘a’ still keeps repeating, because I can’t get out all the aaaaaaaat haaaaairs.

Today the decision about getting a new keyboard was made for me when I clicked the ‘a’ key and the top went flying off across the room.

Categories
Technology Web

Name that space

Recovered from the Wayback Machine.

The fluff about namespaces in RSS 2.0 seems to have boiled down to: the major version number should have warned everyone that this version of the specification isn’t compatible with previous versions. The solution: generate both sets of Userland RSS (0.9x and RSS 2.0) until aggregators can properly work with the namespaces.

Tim Bray wrote in comments at Ben’s:

The best suggestion I’ve seen so far in the thread above is to leave RSS 2.0 with the all the elements in the RSS2.0 namespace, but for publishers to provide 2 different RSS feeds until people get used to it. And then turn off the non-2.0 feeds after a few months. -Tim

First, I agree with Dare Obasanjo — the breakage most likely did occur within aggregators that do support namespaces rather than the reverse; the namespace with RSS 2.0 ‘changed’ and this caused the breakage. However, I disagree with Dare that the solution is to just continue as is and have the RSS generators now create two separate Userland RSS feeds: one for 0.9x and one for 2.0.

How many feeds will we end up with by the time this is done — one for 0.9x, 2.0, and then the RDF/RSS, RSS 1.0 one?

Remember that old chestnut: Poor planning on your part does not make an emergency on mine?

Several things missed with all of this:

  1. Documentation of the namespace support in RSS 2.0 is non-existent, leaving a great deal of confusion about its implementation
  2. Most weblogging tools don’t have the capability of just adding yet another RSS feed, and most webloggers (or others who use software that provides RSS) don’t know how to program enough to generate their own RSS feeds (and those that do, don’t care)
  3. If RSS 2.0 is a major tool release, two weeks to hack it out, implement it, and then shove it into production is a farce — there was no time to allow for third party developers to adapt to the new specification
  4. Focusing on pure technical solutions to what is the result of poor business practices will only postpone these same problems until the next release of something like RSS

However, what I’m saying is not sexy and isn’t full of code. And since I don’t support RSS, it doesn’t impact on me anyway, so why am I talking about it?

One thing I will say, though, is that if RSS 2.0 had been based on RDF/XML, many of the questions arising now about RSS 2.0 would have been answered by the RDF specification, and there wouldn’t be this chaotic scrambling to understand what all of this means (namespace, default or otherwise). RDF/XML is an implementation architecture, and as such, provides a good understanding of what is, or is not, valid XML within the specification. That’s one thing RDF/XML would have provided.