The W3C RDF Data Access Working Group has published the third public working draft of SPARQL Query Language for RDF. According to the introduction,
An RDF graph is a set of triples, each triple consisting of a subject, a predicate and an object, as defined in RDF Concepts and Abstract syntax. These triples can come from a variety of sources. For instance, they may come directly from an RDF document. They may be inferred from other RDF triples. They may be the RDF expression of data stored in other formats, such as XML or relational databases.
SPARQL is a query language for getting information from such RDF graphs. It provides facilities to:
- extract information in the form of URIs, blank nodes, plain and typed literals.
- extract RDF subgraphs.
- construct new RDF graphs based on information in the queried graphs.
As a data access language, it is suitable for both local and remote use. When used across networks, the companion SPARQL Protocol for RDF document describes a remote access protocol.
Here's a simple example SPARQL query adapted from the draft:
PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX : <http://example.org/book/> SELECT $var WHERE { :book1 dc:title $var }
The $
indicates a variable name.
This query stores the
title of a book in a
variable named var
. There are boolean and numeric operators as well.
Norm Walsh has written a RELAX NG schema for XSLT 2.0.