SPARQL Queries

Description

SPARQL is a W3C standard query language. It works with Semantic Web databases, which are also called RDF Stores, Triplestores or SPARQL Endpoints.

Example Code

<div class="plastic-js" style="height: 300px">

    <script class="plastic-query" type="application/sparql-query"
            data-url="http://dbpedia.org/sparql">
        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        PREFIX type: <http://dbpedia.org/class/yago/>
        PREFIX prop: <http://dbpedia.org/property/>

        SELECT ?country_name ?population ?populationCensus
        WHERE {
            ?country a type:LandlockedCountries .
            ?country rdfs:label ?country_name .
            ?country prop:populationEstimate ?population .
            ?country prop:populationCensus ?populationCensus .

            FILTER (?population > 12000000 && langMatches(lang(?country_name), "en")) .
        }
        ORDER BY DESC(?population)
    </script>

    <script class="plastic-display" data-module="discrete-bar-chart" type="application/json">
        {
            "staggerLabels": false,
            "tooltips": false,
            "showValues": true
        }
    </script>

</div>

Live Example

Note

dbpedia is often unreachable or slow. In that case the plastic element below will break.

Options

All options are given via HTML attributes:

type

States the MIME type and the query module / language to be used:

type="application/sparql-query"

data-query-url

URL to SPARQL endpoint:

data-url="http://dbpedia.org/sparql"