Beruflich Dokumente
Kultur Dokumente
RDF Term:
Anonymous
Query Variable:
Triple Pattern:
RDF Triple:
Subject:
IRI
or Blank Node
Predicate:
IRI
Object:
URI:
Graph Pattern:
Basic
Graph Pattern:
Group
Graph Pattern:
Optional
Graph Pattern:
RDF Literal:
Blank Node:
Query Variable:
Union
Graph Pattern:
Graph
Graph Pattern:
Value Constraints:
A node in a graph with a local name. The scope of the name is the RDF graph.
_:node
Common Prefix
rdf:
dc:
foaf:
xsd:
rdfs:
owl:
Namespace URI
http://www.w3.org/1999/02/22-rdf-syntax-ns#
http://purl.org/dc/elements/1.1/
http://xmlns.com/foaf/0.1/
http://www.w3.org/2001/XMLSchema#
http://www.w3.org/2000/01/rdf-schema#
http://www.w3.org/2002/07/owl#
BASE <iri>
PREFIX prefix: <iri> (repeatable)
SELECT (DISTINCT)sequence of ?variable
SELECT (DISTINCT)*
DESCRIBE sequence of ?variable or <iri>
DESCRIBE *
CONSTRUCT { graph pattern }
ASK
Add triples to the background graph (repeatable):
FROM <iri>
Add a named graph (repeatable):
FROM NAMED <iri>
WHERE { graph pattern [ FILTER expression ]}
ORDER BY ...
LIMIT n, OFFSET m
Variable Bindings:
Turtle (Terse RDF Triple Language) describes triples in an RDF graph and allows abbreviations. Triple
Patterns in SPARQL can use the same abbreviations.
RDF Graph:
Describe
Resources:
Build an
RDF graph
Boolean:
Logical:
A|| B, A && B, !A, (A)
Comparison (A op B): =, !=, <, >, <=, >=
Arithmetic operators: Unary:
+A, -A
Binary (A op B):
+, -, *, /
RDF operators:
Boolean:
BOUND(A), isIRI(A) / isURI(A),
isBlank(A), isLiteral(A)
String:
STR(A), LANG(A), DATATYPE(A)
String Match operator:
REGEX(string expression, pattern expression
[,flags expression] )
pattern syntax is from XQuery 1.0 / XPath 2.0,
XML Schema and similar to Perl. flags are s, m, i, x
Extension Functions and
QName( expression, expression, ...)
Explicit Type Casting:
Automatic Type
from xsd:decimal to xsd:float
Promotion:
from xsd:float
to xsd:double
@prefix operator: IRIs can be written as XML-style QNames by defining a prefix / IRI binding:
@prefix dc: <http://purl.org/dc/elements/1.1/> .
Triples: Written as 3 RDF terms with whitespace separating them as necessary, and '.' between triples:
<> dc:title "SPARQL Reference" .
<> dc:date 2006-02-06^^xsd:dateTime .
, operator: Triples with the same subject and predicate may be abbreviated with ',':
<http://example.org/mybook> dc:title My Book, Mein Buch@de .
; operator: Triples with the same subject may be abbreviated with ';':
<http://work.example.org/> dc:title My Workplace;
dc:publisher My Employer .
[ ... ] operator: A sequence of (predicate object) pairs may be put inside [ ... ] and a blank node subject
will be assigned to them:
<> dc:creator [ foaf:name Dave; foaf:homePage <http:...> ] .
[] operator: A blank node:
[] a ex:Book [ dc:title Thing; dc:description On the shelf ] .
a predicate: The often-used rdf:type QName may be abbreviated by the keyword a as a predicate:
<> a Foaf:Document .
Decimal integers: Positive or negative decimal integers can be written directly (type xsd:integer)
<> ex:sizeInBytes 12345 .
Decimal numbers: Positive or negative decimal numbers can be written directly (type xsd:decimal)
<> ex:shoeSize 8.5 .
( ... ) collections: RDF collections can be written inside ( ... ) as a space-separated list of the contents:
<> ex:contents ( ex:apple ex:banana ex:pear ) .
9. Example SPARQL Query
BASE <http://example.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
# This is a relative IRI to BASE above
PREFIX ex: <properties/1.0#>
SELECT DISTINCT $person ?name $age
FROM <http://rdf.example.org/personA.rdf>
FROM <http://rdf.example.org/personB.rdf>
WHERE { $person a foaf:Person ;
foaf:name ?name.
OPTIONAL { $person ex:age $age } .
FILTER (!REGEX(?name, Bob))
}
ORDER BY ASC(?name) LIMIT 10 OFFSET 20