A named query is a SPARQL SELECT query that may be created and edited directly in Callimachus.

Named queries provide “result sets” or answers to questions asked using the SPARQL Query Language. The result sets can be visualized as pie charts, line charts, annotations on Google maps and so on.

Creating named queries

To create a named query, select Named query using the create menu from the folder you wish to store the named query in. You will be presented with the following initial code:

# @Cache-Control:
# @view
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


The following pragmas will use additional query parameters when evaluating the query to produce the result.

Pragma Description
?sparql Responds with the actual SPARQL query used, after subsituting parameters with variables
?results Responds with the SPARQL results as XML
?results&tqx=out:html Formats the results into an HTML table
?results&tqx=out:csv Responds with the SPARQL results as CSV using UTF-8
?results&tqx=out:tsv-excel Responds with the SPARQL results as TSV using UTF-16LE
?results&tqx=out:sparql-json Responds with the SPARQL results as JSON
?results&tqx=out:table Responds with a JSON object with columns property of an array of variable names and rows property of an array of arrays of literals
?results&tqx=out:json Responds with the results formatted into Google's Chart protocol
?view Uses the query's view template (if annotated) to build the response markup

Example Named Query

Here is an example of a named query that shows pollution levels over time.

    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX tri: <http://usepa.3roundstones.net/id/us/fed/agency/epa/tri/schema/>
    PREFIX : <#>

    SELECT DISTINCT ?year ?pounds
    WHERE {
    ?tri_facility owl:sameAs <http://usepa.3roundstones.net/facilities/110000484039>
    ; tri:has_report ?report .

    ?report tri:reports_release_of ?chem
    ; tri:reporting_year ?year
    ; tri:released_to ?location .

    ?chem skos:prefLabel “$chemical” .

    ?location tri:amount_in_pounds ?pounds
    ; tri:environmental_medium <http://usepa.3roundstones.net/id/us/fed/agency/epa/tri/environmental_medium/AIR_STACK> .

    } order by ?year

Source: A Real-World Linked Open Data Story