This document consists of the examples from the SPARQL Query specification. The Makefile has a target examples.html which generated this document. Example run:
make examples.html xsltproc -o examples.html examples-extract.xsl Overview.html
<http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> "SPARQL Tutorial" .
SELECT ?title
WHERE
{
<http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title .
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "title",;
rs:solution [
rs:binding [ rs:variable "title";
rs:value "SPARQL Tutorial" ];
];
.
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE { <http://example.org/book/book1> dc:title ?title }
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://example.org/book/>
SELECT $title
WHERE { :book1 dc:title $title }
BASE <http://example.org/book/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE { <book1> dc:title ?title }
BASE <http://example.org/book/>
PREFIX dcore: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE { <book1> dcore:title ?title }
@prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/book/> . :book1 dc:title "SPARQL Tutorial" .
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?book ?title
WHERE { ?book dc:title ?title }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "?book", "?title",;
rs:solution [
rs:binding [ rs:variable "?book";
rs:value <http://example.org/book/book1> ];
rs:binding [ rs:variable "?book";
rs:value "SPARQL" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Johnny Lee Outlaw" . _:a foaf:mbox <mailto:jlow@example.com> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?mbox
WHERE
{ ?x foaf:name "Johnny Lee Outlaw" .
?x foaf:mbox ?mbox }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "mbox",;
rs:solution [
rs:binding [ rs:variable "mbox";
rs:value <mailto:jlow@example.com> ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Johnny Lee Outlaw" . _:a foaf:mbox <mailto:jlow@example.com> . _:b foaf:name "Peter Goodguy" . _:b foaf:mbox <mailto:peter@example.org> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE
{ ?x foaf:name ?name .
?x foaf:mbox ?mbox }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Johnny Lee Outlaw" ];
rs:binding [ rs:variable "name";
rs:value <mailto:jlow@example.com> ];
];
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Peter Goodguy" ];
rs:binding [ rs:variable "name";
rs:value <mailto:peter@example.org> ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:b foaf:name "Bob" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?x ?name
WHERE { ?x foaf:name ?name }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "x", "name",;
rs:solution [
rs:binding [ rs:variable "x";
rs:value _:c ];
rs:binding [ rs:variable "x";
rs:value "Alice" ];
];
rs:solution [
rs:binding [ rs:variable "x";
rs:value _:d ];
rs:binding [ rs:variable "x";
rs:value "Bob" ];
];
.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "x", "name",;
rs:solution [
rs:binding [ rs:variable "x";
rs:value _:r ];
rs:binding [ rs:variable "x";
rs:value "Alice" ];
];
rs:solution [
rs:binding [ rs:variable "x";
rs:value _:s ];
rs:binding [ rs:variable "x";
rs:value "Bob" ];
];
.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example/ns#> . _:a rdf:subject <http://example.org/book/book1> . _:a rdf:predicate dc:title . _:a rdf:object "SPARQL" . _:a :saidBy "Alice" . _:b rdf:subject <http://example.org/book/book1> . _:b rdf:predicate dc:title . _:b rdf:object "SPARQL Tutorial" . _:b :saidBy "Bob" .
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?book ?title
WHERE
{ ?book dc:title ?title }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "book", "title",;
.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://example/ns#>
SELECT ?book ?title
WHERE
{ ?t rdf:subject ?book .
?t rdf:predicate dc:title .
?t rdf:object ?title .
?t :saidBy " Bob" .
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "book", "title",;
rs:solution [
rs:binding [ rs:variable "book";
rs:value <http://example.org/book/book1> ];
rs:binding [ rs:variable "book";
rs:value "SPARQL Tutorial" ];
];
.
@prefix dt: <http://example.org/datatype#> . @prefix ns: <http://example.org/ns#> . @prefix : <http://example.org/ns#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . :x ns:p "42"^^xsd:integer . :y ns:p "abc"^^dt:specialDatatype . :z ns:p "cat"@en .
SELECT ?v WHERE { ?v ?p 42 }
SELECT ?v WHERE { ?v ?p "abc"^^<http://example.org/datatype#specialDatatype> }
SELECT ?x WHERE { ?x ?p "cat" }
SELECT ?x WHERE { ?x ?p "cat"@en }
@prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> . :book1 dc:title "SPARQL Tutorial" . :book1 ns:price 42 . :book2 dc:title "The Semantic Web" . :book2 ns:price 23 .
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ns: <http://example.org/ns#>
SELECT ?title ?price
WHERE { ?x ns:price ?price .
FILTER (?price < 30) .
?x dc:title ?title . }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "title", "price",;
rs:solution [
rs:binding [ rs:variable "title";
rs:value "The Semantic Web" ];
rs:binding [ rs:variable "title";
rs:value 23 ];
];
.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE {
?x foaf:name ?name .
?x foaf:mbox ?mbox .
}
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { { ?x foaf:name ?name . }
{ ?x foaf:mbox ?mbox . }
}
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . _:a rdf:type foaf:Person . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@example.com> . _:a foaf:mbox <mailto:alice@work.example> . _:b rdf:type foaf:Person . _:b foaf:name "Bob" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name .
OPTIONAL { ?x foaf:mbox ?mbox }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
rs:binding [ rs:variable "name";
rs:value <mailto:alice@example.com> ];
];
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
rs:binding [ rs:variable "name";
rs:value <mailto:alice@work.example> ];
];
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
rs:binding [ rs:variable "name";
rs:value ];
];
.
@prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> . :book1 dc:title "SPARQL Tutorial" . :book1 ns:price 42 . :book2 dc:title "The Semantic Web" . :book2 ns:price 23 .
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ns: <http://example.org/ns#>
SELECT ?title ?price
WHERE { ?x dc:title ?title .
OPTIONAL { ?x ns:price ?price . FILTER (?price < 30) }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "title", "price",;
rs:solution [
rs:binding [ rs:variable "title";
rs:value "SPARQL Tutorial" ];
rs:binding [ rs:variable "title";
rs:value ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "The Semantic Web" ];
rs:binding [ rs:variable "title";
rs:value 23 ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:homepage <http://work.example.org/alice/> . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox ?hpage
WHERE { ?x foaf:name ?name .
OPTIONAL { ?x foaf:mbox ?mbox } .
OPTIONAL { ?x foaf:homepage ?hpage }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox", "hpage",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
rs:binding [ rs:variable "name";
rs:value ];
rs:binding [ rs:variable "name";
rs:value <http://work.example.org/alice/> ];
];
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
rs:binding [ rs:variable "name";
rs:value <mailto:bob@example.com> ];
rs:binding [ rs:variable "name";
rs:value ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> . _:a vcard:N _:x . _:x vcard:Family "Hacker" . _:x vcard:Given "Alice" . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@work.example> . _:b foaf:N _:z . _:z vcard:Family "Hacker" . _:e foaf:name "Ella" . _:e vcard:N _:y . _:y vcard:Given "Eleanor" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
SELECT ?foafName ?mbox ?gname ?fname
WHERE
{ ?x foaf:name ?foafName .
OPTIONAL { ?x foaf:mbox ?mbox } .
OPTIONAL { ?x vcard:N ?vc .
?vc vcard:Given ?gname .
OPTIONAL { ?vc vcard:Family ?fname }
}
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "foafName", "mbox", "gname", "fname",;
rs:solution [
rs:binding [ rs:variable "foafName";
rs:value "Alice" ];
rs:binding [ rs:variable "foafName";
rs:value <mailto:alice@work.example> ];
rs:binding [ rs:variable "foafName";
rs:value "Alice" ];
rs:binding [ rs:variable "foafName";
rs:value "Hacker" ];
];
rs:solution [
rs:binding [ rs:variable "foafName";
rs:value "Bob" ];
rs:binding [ rs:variable "foafName";
rs:value <mailto:bob@work.example> ];
rs:binding [ rs:variable "foafName";
rs:value ];
rs:binding [ rs:variable "foafName";
rs:value ];
];
rs:solution [
rs:binding [ rs:variable "foafName";
rs:value "Ella" ];
rs:binding [ rs:variable "foafName";
rs:value ];
rs:binding [ rs:variable "foafName";
rs:value "Eleanor" ];
rs:binding [ rs:variable "foafName";
rs:value ];
];
.
@prefix dc10: <http://purl.org/dc/elements/1.0/> . @prefix dc11: <http://purl.org/dc/elements/1.1/> . _:a dc10:title "SPARQL Query Language Tutorial" . _:b dc11:title "SPARQL Protocol Tutorial" . _:c dc10:title "SPARQL" . _:c dc11:title "SPARQL (updated)" .
PREFIX dc10: <http://purl.org/dc/elements/1.0/>
PREFIX dc11: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE { { ?book dc10:title ?title } UNION { ?book dc11:title ?title } }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "title",;
rs:solution [
rs:binding [ rs:variable "title";
rs:value "SPARQL Protocol Tutorial" ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "SPARQL" ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "SPARQL (updated)" ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "SPARQL Query Language Tutorial" ];
];
.
PREFIX dc10: <http://purl.org/dc/elements/1.0/>
PREFIX dc11: <http://purl.org/dc/elements/1.1/>
SELECT ?x ?y
WHERE { { ?book dc10:title ?x } UNION { ?book dc11:title ?y } }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "x", "y",;
rs:solution [
rs:binding [ rs:variable "x";
rs:value ];
rs:binding [ rs:variable "x";
rs:value "SPARQL (updated)" ];
];
rs:solution [
rs:binding [ rs:variable "x";
rs:value ];
rs:binding [ rs:variable "x";
rs:value "SPARQL Protocol Tutorial" ];
];
rs:solution [
rs:binding [ rs:variable "x";
rs:value "SPARQL" ];
rs:binding [ rs:variable "x";
rs:value ];
];
rs:solution [
rs:binding [ rs:variable "x";
rs:value "SPARQL Query Language Tutorial" ];
rs:binding [ rs:variable "x";
rs:value ];
];
.
PREFIX dc10: <http://purl.org/dc/elements/1.1/>
PREFIX dc11: <http://purl.org/dc/elements/1.0/>
SELECT ?title ?author
WHERE { { ?book dc10:title ?title . ?book dc10:creator ?author }
UNION
{ ?book dc11:title ?title . ?book dc11:creator ?author }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "author", "title",;
rs:solution [
rs:binding [ rs:variable "author";
rs:value "Alice" ];
rs:binding [ rs:variable "author";
rs:value "SPARQL Protocol Tutorial" ];
];
rs:solution [
rs:binding [ rs:variable "author";
rs:value "Bob" ];
rs:binding [ rs:variable "author";
rs:value "SPARQL Query Language Tutorial" ];
];
.
# Default graph @prefix dc: <http://purl.org/dc/elements/1.1/> . <http://example.org/bob> dc:publisher "Bob" . <http://example.org/alice> dc:publisher "Alice" .
# Named graph: http://example.org/bob @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Bob" . _:a foaf:mbox <mailto:bob@oldcorp.example.org> .
# Named graph: http://example.org/alice @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example.org> .
# Default graph @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:x foaf:name "Bob" . _:x foaf:mbox <mailto:bob@oldcorp.example.org> . _:y foaf:name "Alice" . _:y foaf:mbox <mailto:alice@work.example.org> .
# Named graph: http://example.org/bob @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Bob" . _:a foaf:mbox <mailto:bob@oldcorp.example.org> .
# Named graph: http://example.org/alice @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> .
# Named graph: http://example.org/foaf/aliceFoaf
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
_:a foaf:name "Alice" .
_:a foaf:mbox <mailto:alice@work.example> .
_:a foaf:knows _:b .
_:b foaf:name "Bob" .
_:b foaf:mbox <mailto:bob@work.example> .
_:b foaf:nick "Bobby" .
_:b rdfs:seeAlso <http://example.org/foaf/bobFoaf> .
<http://example.org/foaf/bobFoaf>
rdf:type foaf:PersonalProfileDocument .
# Named graph: http://example.org/foaf/bobFoaf
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
_:z foaf:mbox <mailto:bob@work.example> .
_:z rdfs:seeAlso <http://example.org/foaf/bobFoaf> .
_:z foaf:nick "Robert" .
<http://example.org/foaf/bobFoaf>
rdf:type foaf:PersonalProfileDocument .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?src ?bobNick
WHERE
{
GRAPH ?src
{ ?x foaf:mbox <mailto:bob@work.example> .
?x foaf:nick ?bobNick
}
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "src", "bobNick",;
rs:solution [
rs:binding [ rs:variable "src";
rs:value <http://example.org/foaf/aliceFoaf> ];
rs:binding [ rs:variable "src";
rs:value "Bobby" ];
];
rs:solution [
rs:binding [ rs:variable "src";
rs:value <http://example.org/foaf/bobFoaf> ];
rs:binding [ rs:variable "src";
rs:value "Robert" ];
];
.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX data: <http://example.org/foaf/>
SELECT ?nick
WHERE
{
GRAPH data:bobFoaf {
?x foaf:mbox <mailto:bob@work.example> .
?x foaf:nick ?nick }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "nick",;
rs:solution [
rs:binding [ rs:variable "nick";
rs:value "Robert" ];
];
.
PREFIX data: <http://example.org/foaf/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?mbox ?nick ?ppd
WHERE
{
GRAPH data:aliceFoaf
{
?alice foaf:mbox <mailto:alice@work.example> ;
foaf:knows ?whom .
?whom foaf:mbox ?mbox ;
rdfs:seeAlso ?ppd .
?ppd a foaf:PersonalProfileDocument .
} .
GRAPH ?ppd
{
?w foaf:mbox ?mbox ;
foaf:nick ?nick
}
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "mbox", "nick", "ppd",;
rs:solution [
rs:binding [ rs:variable "mbox";
rs:value <mailto:bob@work.example> ];
rs:binding [ rs:variable "mbox";
rs:value "Robert" ];
rs:binding [ rs:variable "mbox";
rs:value <http://example.org/foaf/bobFoaf> ];
];
.
# Default graph @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix g: <tag:example.org,2005-06-06:> g:graph1 dc:publisher "Bob" . g:graph1 dc:date "2004-12-06"^^xsd:date . g:graph2 dc:publisher "Bob" . g:graph2 dc:date "2005-01-10"^^xsd:date .
# Graph: locally allocated IRI: tag:example.org,2005-06-06:graph1 @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@oldcorp.example.org> .
# Graph: locally allocated IRI: tag:example.org,2005-06-06:graph2 @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@newcorp.example.org> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?name ?mbox ?date
WHERE
{ ?g dc:publisher ?name ;
dc:date ?date .
GRAPH ?g
{ ?person foaf:name ?name ; foaf:mbox ?mbox }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox", "date",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
rs:binding [ rs:variable "name";
rs:value <mailto:bob@oldcorp.example.org> ];
rs:binding [ rs:variable "name";
rs:value "2004-12-06"^^xsd:date ];
];
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
rs:binding [ rs:variable "name";
rs:value <mailto:bob@newcorp.example.org> ];
rs:binding [ rs:variable "name";
rs:value "2005-01-10"^^xsd:date ];
];
.
# Default graph (stored at http://example.org/foaf/aliceFoaf) @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
FROM <http://example.org/foaf/aliceFoaf>
WHERE { ?x foaf:name ?name }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
];
.
# Graph: http://example.org/bob @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Bob" . _:a foaf:mbox <mailto:bob@oldcorp.example.org> .
# Graph: http://example.org/alice @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?src ?name
FROM NAMED <http://example.org/alice>
FROM NAMED <http://example.org/bob>
WHERE
{ GRAPH ?src { ?x foaf:name ?name } }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "src", "name",;
rs:solution [
rs:binding [ rs:variable "src";
rs:value <http://example.org/bob> ];
rs:binding [ rs:variable "src";
rs:value "Bob" ];
];
rs:solution [
rs:binding [ rs:variable "src";
rs:value <http://example.org/alice> ];
rs:binding [ rs:variable "src";
rs:value "Alice" ];
];
.
# Default graph (stored at http://example.org/dft.ttl) @prefix dc: <http://purl.org/dc/elements/1.1/> . <http://example.org/bob> dc:publisher "Bob Hacker" . <http://example.org/alice> dc:publisher "Alice Hacker" .
# Named graph: http://example.org/bob @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Bob" . _:a foaf:mbox <mailto:bob@oldcorp.example.org> .
# Named graph: http://example.org/alice @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example.org> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?who ?g ?mbox
FROM <http://example.org/dft.ttl>
FROM NAMED <http://example.org/alice>
FROM NAMED <http://example.org/bob>
WHERE
{
?g dc:publisher ?who .
GRAPH ?g { ?x foaf:mbox ?mbox }
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "who", "g", "mbox",;
rs:solution [
rs:binding [ rs:variable "who";
rs:value "Bob Hacker" ];
rs:binding [ rs:variable "who";
rs:value <http://example.org/bob> ];
rs:binding [ rs:variable "who";
rs:value <mailto:bob@oldcorp.example.org> ];
];
rs:solution [
rs:binding [ rs:variable "who";
rs:value "Alice Hacker" ];
rs:binding [ rs:variable "who";
rs:value <http://example.org/alice> ];
rs:binding [ rs:variable "who";
rs:value <mailto:alice@work.example.org> ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE
{ ?x foaf:name ?name }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
];
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@org> . _:z foaf:name "Alice" . _:z foaf:mbox <mailto:smith@work> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name WHERE { ?x foaf:name ?name }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:knows _:b . _:a foaf:knows _:c . _:b foaf:name "Bob" . _:c foaf:name "Clare" . _:c foaf:nick "CT" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?nameX ?nameY ?nickY
WHERE
{ ?x foaf:knows ?y ;
foaf:name ?nameX .
?y foaf:name ?nameY .
OPTIONAL { ?y foaf:nick ?nickY }
}
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="nameX"/>
<variable name="nameY"/>
<variable name="nickY"/>
</head>
<results>
<result>
<binding name="nameX">
<literal>Alice</literal>
</binding>
<binding name="nameY">
<literal>Bob</literal>
</binding>
<binding name="nickY">
<unbound/>
</binding>
</result>
<result>
<binding name="nameX">
<literal>Alice</literal>
</binding>
<binding name="nameY">
<literal>Clare</literal>
</binding>
<binding name="nickY">
<literal>CT</literal>
</binding>
</result>
</results>
</sparql>
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "nameX", "nameY", "nickY",;
rs:solution [
rs:binding [ rs:variable "nameX";
rs:value "Alice" ];
rs:binding [ rs:variable "nameX";
rs:value "Bob" ];
rs:binding [ rs:variable "nameX";
rs:value ];
];
rs:solution [
rs:binding [ rs:variable "nameX";
rs:value "Alice" ];
rs:binding [ rs:variable "nameX";
rs:value "Clare" ];
rs:binding [ rs:variable "nameX";
rs:value "CT" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@example.org> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { <http://example.org/person#Alice> vcard:FN ?name }
WHERE { ?x foaf:name ?name }
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> . <http://example.org/person#Alice> vcard:FN "Alice" .
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:givenname "Alice" . _:a foaf:family_name "Hacker" . _:b foaf:firstname "Bob" . _:b foaf:surname "Hacker" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?x vcard:N _:v .
_:v vcard:givenName ?gname .
_:v vcard:familyName ?fname }
WHERE
{
{ ?x foaf:firstname ?gname } UNION { ?x foaf:givenname ?gname } .
{ ?x foaf:surname ?fname } UNION { ?x foaf:family_name ?fname } .
}
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> . _:v1 vcard:N _:x . _:x vcard:givenName "Alice" . _:x vcard:familyName "Hacker" . _:v2 vcard:N _:z . _:z vcard:givenName "Bob" . _:z vcard:familyName "Hacker" .
CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <http://example.org/aGraph> { ?s ?p ?o } . }
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX app: <http://example.org/ns#>
CONSTRUCT { ?s ?p ?o } WHERE
{
GRAPH ?g { ?s ?p ?o } .
{ ?g dc:publisher <http://www.w3.org/> } .
{ ?g dc:date ?date } .
FILTER ( app:customDate(?date) > "2005-02-28T00:00:00Z"^^xsd:dateTime ) .
}
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix site: <http://example.org/stats#> . _:a foaf:name "Alice" . _:a site:hits 2349 . _:b foaf:name "Bob" . _:b site:hits 105 . _:c foaf:name "Eve" . _:c site:hits 181 .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX site: <http://example.org/stats#>
CONSTRUCT { [] foaf:name ?name }
WHERE
{ [] foaf:name ?name ;
site:hits ?hits .
}
ORDER BY ?hits
LIMIT 2
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:x foaf:name "Eve" . _:y foaf:name "Bob" .
DESCRIBE <http://example.org/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?x
WHERE { ?x foaf:mbox <mailto:alice@org> }
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?x
WHERE { ?x foaf:name "Alice" }
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?x ?y <http://example.org/>
WHERE {?x foaf:knows ?y}
PREFIX ent: <http://org.example.com/employees#>
DESCRIBE ?x WHERE { ?x ent:employeeId "1234" }
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0> .
@prefix exOrg: <http://org.example.com/employees#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#>
_:a exOrg:employeeId "1234" ;
foaf:mbox_sha1sum "ABCD1234" ;
vcard:N
[ vcard:Family "Smith" ;
vcard:Given "John" ] .
foaf:mbox_sha1sum rdf:type owl:InverseFunctionalProperty .
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice" . _:a foaf:homepage <http://work.example.org/alice/> . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
ASK { ?x foaf:name "Alice" }
yes
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head></head>
<results>
<boolean>true</boolean>
</results>
</sparql>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
ASK { ?x foaf:name "Alice" ;
foaf:mbox <mailto:alice@work.example> }
no
@prefix a: <http://www.w3.org/2000/10/annotation-ns#> . @prefix dc: <http://purl.org/dc/elements/1.1/> . _:a a:annotates <http://www.w3.org/TR/rdf-sparql-query/> . _:a dc:date "2004-12-31T19:00:00-05:00" . _:b a:annotates <http://www.w3.org/TR/rdf-sparql-query/> . _:b dc:date "2004-12-31T19:01:00-05:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
PREFIX a: <http://www.w3.org/2000/10/annotation-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?annot
WHERE { ?annot a:annotates <http://www.w3.org/TR/rdf-sparql-query/> .
?annot dc:date ?date .
FILTER ( ?date > "2005-01-01T00:00:00Z"^^xsd:dateTime ) }
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . _:a foaf:givenName "Alice". _:b foaf:givenName "Bob" . _:b dc:date "2005-04-04T04:04:04Z"^^xsd:dateTime .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?name
WHERE { ?x foaf:givenName ?name .
OPTIONAL { ?x dc:date ?date } .
FILTER ( bound(?date) ) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "givenName",;
rs:solution [
rs:binding [ rs:variable "givenName";
rs:value "Bob" ];
];
.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?name
WHERE { ?x foaf:givenName ?name .
OPTIONAL { ?x dc:date ?date } .
FILTER (!bound(?date)) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice". _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Bob" . _:b foaf:mbox "bob@work.example" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name ;
foaf:mbox ?mbox .
FILTER isIRI(?mbox) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
rs:binding [ rs:variable "name";
rs:value <mailto:alice@work.example> ];
];
.
@prefix a: <http://www.w3.org/2000/10/annotation-ns#> . @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a a:annotates <http://www.w3.org/TR/rdf-sparql-query/> . _:a dc:creator "Alice B. Toeclips" . _:b a:annotates <http://www.w3.org/TR/rdf-sparql-query/> . _:b dc:creator _:c . _:c foaf:given "Bob". _:c foaf:family "Smith".
PREFIX a: <http://www.w3.org/2000/10/annotation-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?given ?family
WHERE { ?annot a:annotates <http://www.w3.org/TR/rdf-sparql-query/> .
?annot dc:creator ?c .
OPTIONAL { ?c foaf:given ?given ; foaf:family ?family } .
FILTER isBlank(?c)
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "given", "family",;
rs:solution [
rs:binding [ rs:variable "given";
rs:value "Bob" ];
rs:binding [ rs:variable "given";
rs:value "Smith" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice". _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Bob" . _:b foaf:mbox "bob@work.example" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name ;
foaf:mbox ?mbox .
FILTER isLiteral(?mbox) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
rs:binding [ rs:variable "name";
rs:value "bob@work.example" ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice". _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Bob" . _:b foaf:mbox <mailto:bob@home.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name ;
foaf:mbox ?mbox .
FILTER regex(str(?mbox), "@work.example") }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
rs:binding [ rs:variable "name";
rs:value <mailto:alice@work.example> ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Robert"@EN. _:a foaf:name "Roberto"@ES. _:a foaf:mbox <mailto:bob@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name ;
foaf:mbox ?mbox .
FILTER ( lang(?name) = "ES" ) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "mbox",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Roberto"@ES ];
rs:binding [ rs:variable "name";
rs:value <mailto:bob@work.example> ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix eg: <http://biometrics.example/ns#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . _:a foaf:name "Alice". _:a eg:shoeSize "9.5"^^xsd:float . _:b foaf:name "Bob". _:b eg:shoeSize "42"^^xsd:integer .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX eg: <http://biometrics.example/ns#>
SELECT ?name ?size
WHERE { ?x foaf:name ?name ; eg:shoeSize ?size .
FILTER ( datatype(?size) = xsd:integer ) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name", "shoeSize",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Bob" ];
rs:binding [ rs:variable "name";
rs:value 42 ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice". _:a foaf:mbox <mailto:alice@work.example> . _:b foaf:name "Ms A.". _:b foaf:mbox <mailto:alice@work.example> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name1 ?name2
WHERE { ?x foaf:name ?name1 ;
foaf:mbox ?mbox1 .
?y foaf:name ?name2 ;
foaf:mbox ?mbox2 .
FILTER (?mbox1 = ?mbox2 && ?name1 != ?name2)
}
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name1", "name2",;
rs:solution [
rs:binding [ rs:variable "name1";
rs:value "Alice" ];
rs:binding [ rs:variable "name1";
rs:value "Ms A." ];
];
rs:solution [
rs:binding [ rs:variable "name1";
rs:value "Ms A." ];
rs:binding [ rs:variable "name1";
rs:value "Alice" ];
];
.
@prefix a: <http://www.w3.org/2000/10/annotation-ns#> . @prefix dc: <http://purl.org/dc/elements/1.1/> . _:b a:annotates <http://www.w3.org/TR/rdf-sparql-query/> . _:b dc:date "2004-12-31T19:00:00-05:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
PREFIX a: <http://www.w3.org/2000/10/annotation-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?annotates
WHERE { ?annot a:annotates ?annotates .
?annot dc:date ?date .
FILTER ( ?date = xsd:dateTime("2004-01-01T00:00:00Z") || ?date = xsd:dateTime("2005-01-01T00:00:00Z") ) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "annotates",;
rs:solution [
rs:binding [ rs:variable "annotates";
rs:value <http://www.w3.org/TR/rdf-sparql-query/> ];
];
.
@prefix dc: <http://purl.org/dc/elements/1.1/> . _:a dc:title "That Seventies Show"@en . _:a dc:title "Cette Série des Années Soixante-dix"@fr . _:a dc:title "Cette Série des Années Septante"@fr-BE . _:b dc:title "Il Buono, il Bruto, il Cattivo" .
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE { ?x dc:title "That Seventies Show"@en ;
dc:title ?title .
FILTER langMatches( lang(?title), "FR" ) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "title",;
rs:solution [
rs:binding [ rs:variable "title";
rs:value "Cette Série des Années Soixante-dix"@fr ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "Cette Série des Années Septante"@fr-BE ];
];
.
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE { ?x dc:title ?title .
FILTER langMatches( lang(?title), * ) }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "title",;
rs:solution [
rs:binding [ rs:variable "title";
rs:value "That Seventies Show"@en ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "Cette Série des Années Soixante-dix"@fr ];
];
rs:solution [
rs:binding [ rs:variable "title";
rs:value "Cette Série des Années Septante"@fr-BE ];
];
.
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Alice". _:b foaf:name "Bob" .
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE { ?x foaf:name ?name
FILTER regex(?name, "^ali", "i") }
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#> .
[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
rs:ResultSet ;
rs:resultVariable "name",;
rs:solution [
rs:binding [ rs:variable "name";
rs:value "Alice" ];
];
.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX func: <http://example.org/functions#>
SELECT ?name ?id
WHERE { ?x foaf:name ?name ;
func:empId ?id .
FILTER (func:even(?id)) }
PREFIX aGeo: <http://example.org/geo#>
SELECT ?neighbor
WHERE { ?a aGeo:placeName "Grenoble" .
?a aGeo:location ?axLoc .
?a aGeo:location ?ayLoc .
?b aGeo:placeName ?neighbor .
?b aGeo:location ?bxLoc .
?b aGeo:location ?byLoc .
FILTER ( aGeo:distance(?axLoc, ?ayLoc, ?bxLoc, ?byLoc) < 10 ) .
}