RDF Query in Javascript demo

Status of this document: this is early access to a work in progress, released in current form for feedback/comments from the RDF Interest Group. See changes log below for recent changes and the disclaimer below for more warnings, apologies etc if the demo fails in your browsing environment.

Nearby in the Web: Inkling, An SquishQL RDF Query implementation, RDFdb at SourceForge

This demonstration accompanies the WWW Proposal in RDF document, and shows (in some Javascript-enabled browsers) how the combination of URI identifiers and the RDF data model allows us to query information structures similar to those represented in the figure from the WWW proposal.

Authors: This document, examples and rdfquery.js glue code: Dan Brickley; based on Javascript prolog engine by Jan Grant.


Usage: enter RDF queries using these forms. Some pre-prepared sample queries are provided. Note that a separate browser window is opened to display HTMLised results, and that this may sometimes be obscured by other windows.

Examples

This query lists all pairs of nodes connected by an 'rdf:type' arc

This query lists resources having Title/Creator/Description properties:

Here we find all pairs of resources R1 and R2 where R1 'includes' R2:

Or... find all pairs of resources R1 and R2 where R1 'unifies' R2:

Query Results (textual log)

(See also HTML table view of results in separate window)

Explanation

What exactly is going on here? When the demo works, the 'results' textarea and a separate HTML browser window are used to display the results of RDF queries. These are run locally in Javascript; the only role played by the server is fileserving. See the files prolog.js and rdfquery.js for the implementation. The latter file (and some crude edits to prolog.js) allow Javascript code in this document to send queries, data and rules to the core prolog.js system. The query language shown here is an ad-hoc Prolog derrivative. Capital letters denote variables; query results consist of a series of sets of variable to resource/literal bindings.

The syntax is an extended form of Prolog which uses URIs (indicated by {curly-braces} and "quoted strings". Although not shown here, the system also supports the expression of simple inference rules; see Jan Grant's Prolog in Javascript page for examples of this. To augment the ruleset and database, simply edit the large textarea at the foot of this page.

RDF Database

Note that the above queries are over the RDF statements listed below. An interactive version of this demo is in development (not always available) that allows multiple networked RDF datasources and description services to be consulted. Since we do not have access to an RDF or XML parser within the current Javascript application, the query system instead consumes an alternative 'triples'-based representation of RDF. This is trivial to emit from server-based RDF parser. It would also be nice to explore XSL-to-RDF translations of 'colloquial' XML data...

The data shown below is in the form {predicate} ( {subject}, {object} ). One RDF statement per line.

Recent Changes

Disclaimer: this demo uses clientside Javascript to demonstrate an RDF Query prototype implementation. There are known problems with some Javascript implementations. For non-JS environments, see the RDF pages for a number of other logic and query systems applicable to RDF. Note that a query with 0 results will currently result in an error; this is due to danbri's code in rdfquery.js and not a failing in Jan Grant's prolog engine!

Known bugs: some problems on Macintosh (Netscape Navigator) at least, possibly to do with line ending characters. Javascript errors in Win32 Navigator 4.06.

Please note, these pages do not currently validate properly; this will be fixed as soon as this document's author learns enough Javascript to Do The Right Thing and fix the use of the 'NAME' attribute.

$Id: rdfqdemo.html,v 1.2 2001/07/28 01:06:29 danbri Exp $