A named query template determines how query results from a Named Query are displayed. Each template is associated with a Named Query using the SPARQL comment # @view. When this comment is present in the query, the queries' view tab will return the markup in the template. The template can then use JavaScript to load the query results (shown below) or if the query has exactly one variable in the SELECT clause, the template can walk the graph from the results of that variable binding as described in View Templates for Named Queries.

Named Query code

# @view pie-chart.xhtml
PREFIX skos:<>
PREFIX vcard:<>
PREFIX directory:<>
SELECT ?label (count(distinct ?proj) as ?value) {
    ?proj directory:isOrganizationType [ skos:prefLabel ?label ]
} GROUP BY ?label ORDER BY desc(?value)

View template code

<html xmlns="">
    <title>Pie Chart</title>
    <script src="" type="text/javascript"> </script>
    <script type="text/javascript">
        google.load("visualization", "1", {callback: function(){
            var chart = new google.visualization.ChartWrapper({
    <div class="container">
        <h1>Pie Chart</h1>
        <div id="pie-chart" class="chart" style="height:300px;width:400px"></div>