<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>SPARCool: SPARQL made easy</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Using SPARCool</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Digital Enterprise Research Institute, National University of Ireland</institution>
          ,
          <addr-line>Galway</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper introduces the motivations and technical details behind SPARCool, a web service that provides an easy way to run SPARQL queries on the Web by calling a simple URL pattern1. Thanks to the Linking Open Data2 community project, million of resources, identi ed by their URI, are now described on the Web thanks to RDF(S)/OWL technologies. To e ciently take advantage of it and go further than simple browsing, developers must use either SPARQL or RDF(S)/OWL APIs to query and use this data. Yet, it can be complex for Web developers that are not necessarily aware of such languages. SPARCool3 aims to solve this gap by providing a way to let people easily run SPARQL queries on any URI that follows the Linked Data principles4 [1] without learning the SPARQL syntax, and then build applications using the query answers. In order to run SPARQL queries with SPARCool, one just have to call the URL pattern http://sparcool.net/format/predicate[;l=lang]/URI, that is translated into a SPARQL query applied to the URI given as a parameter. The format parameter indicates the required output and can be (1) XML SPARQL Query results, (2) JSON SPARQL Query results, (3) HTML view of the results, either plain-HTML (for a single result) or using a &lt;ul/&gt; list (for multiple results) and (4) a redirect to the rst query of the answer, for instance for hyperlinks or images. The predicate must be written using a QName syntax and a set of pre xes are supported by SPARCool, while the lang parameter is optional.</p>
      </abstract>
      <kwd-group>
        <kwd>SPARQL</kwd>
        <kwd>Linked Data</kwd>
        <kwd>SPARCool</kwd>
        <kwd>JSONP</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Motivations</title>
      <p>While the two rst types of results (XML and JSON serialization of SPARQL
query results) imply additional work if developers want to integrate it into
webpages, the HTML view and the redirect can be used to directly expose results
in HTML pages. Especially, SPARCool also supports JSONP5 callbacks, so that
the HTML results of SPARCool calls can be embedded directly in (X)HTML
pages on client side, without having to face AJAX cross-domain security issues.
That way, it enables to construct dynamic and constantly up-to-date webpages:
if the information about a particular URI changes (e.g. a foaf:homepage value),
the webpage will be automatically adapted.</p>
      <p>Examples of SPARCool queries, using various result formats, can be found
on the service website: http://sparcool.net.
3</p>
    </sec>
    <sec id="sec-2">
      <title>Query translation</title>
      <p>http://sparcool.net/j/foaf:name;l=fr/http://example.org/Bob#b will be
translated into the following query6, and results will be serialized in JSON.
FROM &lt;http://example.org/Bob#b&gt;
SELECT ?value
WHERE {
&lt;http://example.org/Bob#b&gt; rdf:label ?value .</p>
      <p>FILTER (lang(?value) = 'en')
}</p>
      <p>Since the FROM parameter is applied to the same URI used in the query
pattern, this URI must follow the Linked Data principles, especially being
dereferencable and returning (machine-readable) information about itself, whatever
the RDF serialization it (RDFa, RDF/XML, etc.).</p>
    </sec>
    <sec id="sec-3">
      <title>4 Implementation</title>
      <p>SPARQL is provided thanks to a PHP script (less than 100 lines of code) that
translates the called URI (thanks to Apache RewriteRule) to a SPARCool object
that contains the generated SPARQL query and additional parameters (output
format and JSONP callback if any). The query is then launched using roqet
(part of Redland7) and the results are intercepted by the SPARCool object that
sets the proper content-type and returns the results in the browser.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Tim</given-names>
            <surname>Berners-Lee</surname>
          </string-name>
          .
          <article-title>Linked Data. Design issues for the world wide web</article-title>
          ,
          <source>World Wide Web Consortium</source>
          ,
          <year>2006</year>
          . http://www.w3.org/DesignIssues/LinkedData.html.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>5 http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/ 6 Pre xes ommited</mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>7 http://librdf.org</mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>