August 23rd, 2018
Wouter Beek (wouter@triply.cc)
select * {
?s ?p ?o.
}
limit 5
select *
*
means bindings for all variables are
returned.{ ?s ?p ?o. }
limit 5
select * {
?image <https://triply.cc/rce/def/locator> ?url.
}
limit 5
<https://triply.cc/rce/def/locator>
?p
with an IRI.?image
and ?url
select ?url {
?image <https://triply.cc/rce/def/locator> ?url.
}
limit 5
?url
?url
in
the projection.?image
bind
select * {
?image <https://triply.cc/rce/def/locator> ?url.
bind(concat('<a href="',?image,'"><img src="',?url,'"><a>') as ?widget)
}
limit 5
bind(EXPRESSION) as ?x
EXPRESSION
is bound to ?x
.concat(STRING,…)
select * {
?image <https://triply.cc/rce/def/locator> ?url.
}
limit 6
select * {
?image <https://triply.cc/rce/def/locator> ?url.
}
limit 5
offset 5
offset 5
select * {
?image <https://triply.cc/rce/def/locator> ?url.
?image <http://xmlns.com/foaf/0.1/depicts> ?monument.
}
limit 5
?image
select * {
?image <https://triply.cc/rce/def/locator> ?url.
?image <http://xmlns.com/foaf/0.1/depicts> ?monument.
?monument <http://www.w3.org/2000/01/rdf-schema#label> ?label.
}
limit 5
http://xmlns.com/foaf/0.1/depicts
http://www.w3.org/2000/01/rdf-schema#
select * {
?image <https://triply.cc/rce/def/locator> ?url.
?image <http://xmlns.com/foaf/0.1/depicts> ?monument.
?monument <http://www.w3.org/2000/01/rdf-schema#label> ?label.
?monument <https://triply.cc/rce/def/bouwjaar> ?year.
}
limit 5
select * {
?image <https://triply.cc/rce/def/locator> ?url.
?image <http://xmlns.com/foaf/0.1/depicts> ?monument.
?monument <http://www.w3.org/2000/01/rdf-schema#label> ?label.
?monument <https://triply.cc/rce/def/bouwjaar> ?year.
}
order by ?year
limit 5
order by ?x
?x
.select * {
?image <https://triply.cc/rce/def/locator> ?url.
?image <http://xmlns.com/foaf/0.1/depicts> ?monument.
?monument <http://www.w3.org/2000/01/rdf-schema#label> ?label.
?monument <https://triply.cc/rce/def/bouwjaar> ?year.
}
order by desc(?year)
limit 5
order by desc(?x)
?x
.prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix rce: <https://triply.cc/rce/def/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select * {
?image rce:locator ?url;
foaf:depicts ?monument.
?monument rdfs:label ?label;
rce:bouwjaar ?year.
}
order by desc(?year)
limit 5
prefix ALIAS: <IRI>
IRI
to be abbreviated
with ALIAS
+ colon.;
after an object termprefix geo: <http://www.opengis.net/ont/geosparql#>
select * {
?monument geo:hasGeometry ?geometry.
?geometry geo:asWKT ?shape.
}
limit 1000
geo:hasGeometry
and geo:asWKT
prefix geo: <http://www.opengis.net/ont/geosparql#>
select * {
?monument geo:hasGeometry/geo:asWKT ?shape.
}
limit 1000
p/q
p
and then
property q
(and do not bind the node
in between).prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix owl: <http://www.w3.org/2002/07/owl#>
select * {
{
select * {
?monument geo:hasGeometry/geo:asWKT ?shape1;
owl:sameAs ?pand.
}
limit 10
}
service <https://data.pdok.nl/sparql> {
?pand geo:hasGeometry/geo:asWKT ?shape2.
}
}
service <IRI> { QUERY }
QUERY
on
endpoint IRI
.prefix bag: <http://bag.basisregistraties.overheid.nl/def/bag#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?shape {
service <https://data.pdok.nl/sparql> {
?woonplaats rdfs:label "Amsterdam"@nl.
?openbareRuimte bag:bijbehorendeWoonplaats ?woonplaats;
bag:naamOpenbareRuimte "De Boelelaan".
?nummeraanduiding bag:bijbehorendeOpenbareRuimte ?openbareRuimte;
bag:huisnummer 1105;
bag:postcode "1081HV".
?verblijfsobject bag:hoofdadres ?nummeraanduiding;
bag:pandrelatering ?pand.
?pand geo:hasGeometry/geo:asWKT ?shape.
}
}
limit 1
prefix bag: <http://bag.basisregistraties.overheid.nl/def/bag#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select ?shape ?shapeLabel {
?verblijfsobject bag:hoofdadres/bag:bijbehorendeOpenbareRuimte/bag:bijbehorendeWoonplaats/bag:naamWoonplaats "Apeldoorn"^^xsd:string;
bag:pandrelatering ?pand.
?pand bag:geometriePand/geo:asWKT ?shape;
bag:oorspronkelijkBouwjaar ?shapeLabel.
}
order by asc(?shapeLabel)
limit 50
prefix brt: <http://brt.basisregistraties.overheid.nl/def/top10nl#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select ?shape ?shapeLabel {
?place1 brt:isBAGwoonplaats true;
geo:hasGeometry/geo:asWKT ?shape;
rdfs:label "Swalmen"^^xsd:string.
service <https://dbpedia.org/sparql> {
?place2 foaf:depiction ?vlag;
rdfs:label "Swalmen"@nl.
}
}
limit 1
service <URL> { A }
means that
subquery A
is executed on a different
SPARQL endpoint. The results are received from that
endpoint, and integrated within the overall query
results.
prefix brt: <http://brt.basisregistraties.overheid.nl/def/top10nl#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select ?shape ?shapeLabel {
?place1 brt:isBAGwoonplaats true;
geo:hasGeometry/geo:asWKT ?shape;
rdfs:label "Apeldoorn"^^xsd:string.
service <https://dbpedia.org/sparql> {
?place2 rdfs:label "Apeldoorn"@nl.
optional { ?place2 foaf:depiction ?vlag. }
}
}
limit 1
When you query the web, not all information is there all
the time. optional { A }
makes the query
resilient against missing information.
@WGJBeek