Callimachus supports the ability to assign a view template to a specific name query. It is quite a simple process and only requires two separate files: a query and a template. It does not matter which is created first but the two are dependent on each other, and thus both must exist to function correctly.

The Query

Queries that use view templates are not structured differently than queries that do not. The only difference is in a comment at the top of the query. In order to add a view template to a query, we add a comment with @view to include the relative filepath and name of the template we wish to apply.

# @Cache-Control: max-age=3600
# @view concept-search.xhtml
PREFIX skos:<>

SELECT ?concept {
  ?concept a skos:Concept; skos:prefLabel ?label
  FILTER regex(?label, "$q", "i")
} ORDER BY ?concept LIMIT 10

Example 1: Named query that uses a view template

Be aware that once you have added a view template to a named query, when you hit the View tab it will no longer appear as a table of query results. It will now be rendered through the template. You can still edit the query itself by simply clicking the Edit tab.

The Template

The template behaves as any other Callimachus template does, relying on RDFa markup to "traverse" the graph and display the apporpriate data. For more information about templates see the full documentation. As you can see below by adding just a few attributes to existing html tags we are able to display the results of the query as if the query was  occuring within that page.

<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns=""
    <title>Concept Search Results</title>
    <link rel="edit-form" href="?edit" />
    <link rel="comments" href="?discussion" />
    <link rel="describedby" href="?describe" />
    <link rel="version-history" href="?history" />
    <h1>Concept Search Results</h1>
        <li resource="?concept">
            <a href="{?concept}">{skos:prefLabel}</a>
            <pre property="skos:definition" />

Example 2. View template for named query

Above we have added a few crucial pieces of information to the existing HTML tags. Since this template is now associated with a named query (completed in the step above) the template is able to reference the variable in the SELECT clause of the query. As you can see, the resource attribute of the <li> is now connected to ?concept, the variable that was returned in the results of the named query. From here we are able to pick and choose the data we want to display and how to display it. An HTTP request to "concept-search.rq?view&q=sun" will include any concept with the regex "sun" in the pref label.