XsRQL: an XQuery-style Query Language for RDF

A submission to the RDF Data Access Working Group (DAWG)

Howard Katz <howardk@fatdog.com>
June 27, 2004

Table of Contents

Introduction

Language objectives

This document

Feature summary

XsRQL path language

A brief tutorial

Examples
Example 1: Marriage partners

Example 2: Plotting people on a map

Example 3: Finding hypernyms with WordNet

Example 4: Libby Miller's papers

Example 5: Libby's mailbox

Example 6: Libby's optional mailbox

XsRQL grammar

Introduction

XsRQL is a query language for RDF that derives much of its syntax and style from XQuery, hence its name: an XQuery-style RDF Query Language. The idea is to reuse many of the useful and innovative features and metaphors the XML Query Working Group spent so many thousands of hours developing, while omitting the more complex parts of the XQuery specification that are specific to XML and not required in an RDF environment.

The "style" qualifier in the name is important: XsRQL sits on top of an RDF data model and knows nothing about XML or the complexities of the XQuery data model; on the other hand, it borrows happily and unashamedly from the XQuery surface syntax, its concept of an underlying, formal data model, its functional programming metaphor, and a number of the other innovations pioneered by the XML Query working group that are described below.

The basic idea is to reuse some of the fruits of the tens of thousands of long hours and hard work the working group put into XQuery, arguably the W3C's most complex specification. In the end, RDF is far simpler than XML, and XsRQL is correspondingly far simpler than XQuery. It shamelessly steals, er, borrows, much of what's best about XQuery and ignores the rest.

I've tried to keep the amount of blue-skying in the following to a minimum (though I might not have always succeeded; some of the sample code below has yet to see silicon, and it's hard not to occasionally wax rhapsodic, particularly with a cider or two in hand.) I've implemented much of the path language in prototype form and hope to be able to demo some live code at the face-to-face in San Diego.

Language objectives

The main objectives of XsRQL are:

  1. to keep the language as simple and as elegant as possible (something the author is not necessarily in the best position to judge),


  2. to provide the end user the opportunity of choosing a query style that sits, at his or her own discretion, somewhere on a continuum between concise-but-readable and a more verbose style that's as self-documenting as desired, and


  3. to allow the user a similar choice on the emit side of the equation between result-sequence concision and a full-blown, ad hoc report-generating capability.

This document

This document looks briefly at the XsRQL feature set, most of which are drawn directly or indirectly from existing mechanisms in XQuery, provides numerous code snippet examples of the path language that's central to XsRQL, works its way through a somewhat herky-jerky tutorial overview of the language in general, and finishes by providing several illustrative examples of XsRQL queries compared and contrasted with similar queries in RDQL and other existing RDF query languages.

As well, a working prototype of an early first cut at a JavaCC grammar is attached (if only to prove that the author isn't living entirely in cloud cuckoo land.)

For those who are impatient to get up to speed and don't derive as much pleasure listening to the author speak as he does himself, I'd suggest jumping right into working code: work your way through the numerous code snippets in the sections on the XsRQL path language and the Examples.

Lastly, thanks to Andy Seaborne of HP Labs whose Jena tutorial was helpful in bringing me up to speed on RDQL, and whose look and feel so impressed me with its straightforward simplicity (the document that is, not Andy) that I have, with his concurrence, adopted its style as my own.

Feature summary

The main features of XsRQL that are drawn directly from or are inspired by XQuery are:

Functional language