Linked Open Data: Sparql test
The SPARQL endpoint is: http://opendata.euskadi.eus/es/sparql
The SPARQL endpoint can be queried via GET or POST and the expected result differs depending on the accepted mime-type (the Accept HTTP header).
If [accept] header is HTML (for example) using a web browser, a SPARQL GUI is presented. Using this GUI anyone can issue SPARQL queries to the [triple-store].
- Using a web browser enter:
http://opendata.euskadi.eus/es/sparql
- Enter the following SPARQL] query:
Test 1: Describe the resource of the General Administration of the Basque Country
DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>
The expected result is (Prefixes not shown for brevity):
<http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi> <http://schema.org/mainEntityOfPage> <http://www.euskadi.eus> ;
owl:sameAs <http://datos.gob.es/recurso/sector-publico/territorio/Autonomia/Pais-Vasco> .
Test 2: Metadata
PREFIX graph:<http://id.euskadi.eus/graph/>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
SELECT DISTINCT ?loddistribution ?otherdistribution
WHERE {
?maindistribution dcat:distribution ?loddistribution .
?maindistribution dcat:distribution ?otherdistribution .
?loddistribution sd:namedGraph graph:bopv-european-legislation-identifier-eli .
GRAPH graph:bopv-european-legislation-identifier-eli {
?sub ?pred ?obj
}
}
Test 3: ELI legal resources ordered by date
PREFIX schema: <http://schema.org/>
PREFIX eli: <http://data.europa.eu/eli/ontology#>
PREFIX graph:<http://id.euskadi.eus/graph/>
SELECT DISTINCT ?datePub ?legeguneaurl ?title
WHERE {
GRAPH graph:bopv-european-legislation-identifier-eli {
?legalresource eli:date_publication ?datePub .
?legalresource eli:is_realized_by ?legalexpresion .
?legalexpresion eli:title ?title .
?eliformat eli:embodies ?legalexpresion .
?eliformat schema:mainEntityOfPage ?legeguneaurl .
}
}
ORDER BY ASC (?datePub)
Test 4: ELI legal resources between two dates
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX schema: <http://schema.org/>
PREFIX eli: <http://data.europa.eu/eli/ontology#>
PREFIX graph:<http://id.euskadi.eus/graph/>
SELECT DISTINCT ?datePub ?legeguneaurl ?title
WHERE {
GRAPH graph:bopv-european-legislation-identifier-eli {
?legalresource eli:date_publication ?datePub .
?legalresource eli:is_realized_by ?legalexpresion .
?legalexpresion eli:title ?title .
?eliformat eli:embodies ?legalexpresion .
?eliformat schema:mainEntityOfPage ?legeguneaurl .
}
FILTER (?datePub > "1936-01-01"^^xsd:date && ?datePub < "1938-01-01"^^xsd:date)
}
Test 5: ELI legal resources between two dates and title contains a string
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX schema: <http://schema.org/>
PREFIX eli: <http://data.europa.eu/eli/ontology#>
PREFIX graph:<http://id.euskadi.eus/graph/>
SELECT DISTINCT ?datePub ?legeguneaurl ?title
WHERE {
GRAPH graph:bopv-european-legislation-identifier-eli {
?legalresource eli:date_publication ?datePub .
?legalresource eli:is_realized_by ?legalexpresion .
?legalexpresion eli:title ?title .
?eliformat eli:embodies ?legalexpresion .
?eliformat schema:mainEntityOfPage ?legeguneaurl .
}
FILTER (?datePub > "1936-01-01"^^xsd:date && ?datePub < "1938-01-01"^^xsd:date)
FILTER regex (str(?title), "^Orden", "i")
}
Test 6: ELI predicates
PREFIX graph:<http://id.euskadi.eus/graph/>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
SELECT ?pred
WHERE {
GRAPH graph:bopv-european-legislation-identifier-eli {
?sub ?pred ?obj
}
}
If [accept] header is RDF (or turtle or whatever), the query is just directed (proxied) to the [triple-store], SPARQL endpoint and executed.
Test
Using an HTTP client GUI, for example POSTMAN or CURL:
If using GET http method
Url: http://id.euskadi.eus/sparql/?query=DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>
Method: GET
Accept header: Accept=rdf
CURL: curl -X GET 'http://id.euskadi.eus/sparql/?query=DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>' \
-H 'accept: application/rdf+xml'
Result: an RDF representation of the query result.
If using POST http method
Url: http://id.euskadi.eus/sparql/?query=DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>
Method: POST
Accept header: Accept=rdf
Body: form url encoded
query=DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>
CURL: curl -X POST http://id.euskadi.eus/sparql/ \
-H 'accept: application/rdf+xml' \
-H 'content-type: application/x-www-form-urlencoded' \
-d query=DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>
Result: an RDF representation of the query result.