<!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>SPARQLAS - Implementing SPARQL Queries with OWL Syntax</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Mark Schneider</string-name>
          <email>mschneider@uni-koblenz.de</email>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute for Web Science and Technologies University of Koblenz-Landau Universitaetsstrasse 1</institution>
          ,
          <addr-line>Koblenz 56070</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Using SPARQL for writing queries on OWL-DL ontologies can be complicated due to its RDF triple semantics. Translating OWL expressions to this semantics is a non-trivial problem. We present SPARQLDL Abstract Syntax (SPARQLAS), a proper subset of SPARQL, to solve this issue by employing the OWL Functional-Style Syntax to compose queries. We illustrate how the translation is made possible by a modelto-model transformation and how a query can be connected to an UML model. Finally, we evaluate SPARQLAS against SPARQL and show the e orts of SPARQLAS for queries on OWL-DL ontologies.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        With the W3C recommendation for SPARQL [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] as the query language for
RDF, querying OWL-DL ontologies can be quite complicated. Having OWL
Functional-Style Syntax [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] recommended to write new ontologies, it becomes
more di cult than necessary to query such ontologies using SPARQL. The main
problem lies in SPARQL and its RDF triple semantics. If a user wants to query
an OWL-DL ontology, he needs to translate his accustomed OWL syntax to the
proper representation in RDF triples. This translation, if done manually, can be
time consuming and is prone to syntactic as well as to semantic errors.
      </p>
      <p>
        Existing approaches, which do not rely on RDF triples to speci cally query
OWL-DL ontologies, are lacking in di erent aspects. Terp [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] uses SPARQL as its
query language and allows Manchester Syntax constructs to simplify the query.
However, Terp is dependent on Pellet as its SPARQL processing engine and is
consequently not applicable to other engines. SAIQL [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] introduces a new
OWLDL query language that solves the RDF triples issue, but it is not compatible
to SPARQL. jOWL's implementation of SPARQL-DL [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] resolves the problem
by applying OWL Functional-Style Syntax like axioms for querying, yet it only
covers a restricted set of OWL-DL expressions.
      </p>
      <p>Therefore, we introduce SPARQL-DL Abstract Syntax (SPARQLAS) that
combines employing SPARQL to query OWL-DL ontologies and using OWL
Functional-Style Syntax to compose queries. With SPARQLAS, the user does
not have to translate between two languages, but is still able to utilize any
SPARQL processing engine that supports the OWL-DL entailment regime. The
optional application of a shortened version of the OWL Functional-Style Syntax
simpli es queries even more.</p>
      <p>These advantages of SPARQLAS are accomplished by creating a new and
more readable syntax out of SPARQL and the OWL Functional-Style Syntax
and by transforming SPARQLAS to SPARQL. The transformation itself makes
a special SPARQLAS processing engine needless and assures an easy embedding
of SPARQLAS into running IDEs.</p>
      <p>In the following, we rst present in Section 2 the implementation of
SPARQLAS at the TwoUse Toolkit. There we elaborate the conceptual approach
of how a SPARQLAS query is parsed, transformed and printed to a SPARQL
query before discussing the realization of the textual syntax and the core
transformation. In Section 3 we show a concrete application example and in Section
4 we evaluate the e orts of SPARQLAS against SPARQL. Finally in Section 5,
we conclude and discuss some future work.</p>
      <p>
        The example throughout this paper deals with the commonly known wine
ontology [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and is querying for the region in which German wine is located.
      </p>
    </sec>
    <sec id="sec-2">
      <title>Implementation</title>
      <sec id="sec-2-1">
        <title>Conceptual Approach</title>
        <p>To get a SPARQLAS query translated to a SPARQL query, we rst need to
de ne a meta model for each language so that a model transformation can be
performed upon. For writing a SPARQLAS query and a subsequent use of a
SPARQL query, those meta models have to be linked to a textual syntax. Fig.
1 illustrates the conceptual approach and shows what steps need to be realized
for the complete translation.</p>
        <p>
          Both textual syntaxes to SPARQLAS and SPARQL are created by using
the Eclipse plug-in EMFText1. EMFText is able to generate a textual syntax
derived from a meta model in Ecore [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ] and a grammar in EBNF [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] notation.
It also provides the parser to achieve an EMF Resource from a SPARQLAS
        </p>
        <sec id="sec-2-1-1">
          <title>1 http://www.emftext.org/index.php/EMFText</title>
          <p>query and the printer to compose a SPARQL query out of an EMF Resource.
The actual translation between both EMF Resources is performed by an ATL2
model-to-model transformation.</p>
        </sec>
      </sec>
      <sec id="sec-2-2">
        <title>2.2 Textual Syntax</title>
        <p>
          The rst action for implementing SPARQLAS is developing its textual syntax
with EMFText, since a textual syntax for SPARQL is already available at the
EMFText Concrete Syntax Zoo [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. SPARQLAS is based on the theoretical
concepts of SPARQL-DL [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ] and adopts the framework of SPARQL, but replaces
the RDF triples inside its Where clause by the OWL Functional-Style Syntax or
a shortened version of it. There are all four kinds of queries supported, namely
Select, Construct, Ask and Describe. One of SPARQLAS' goals is to make queries
more readable, thus some SPARQL constructs are either simpli ed or completely
omitted. For example there is no di erence between BASE and PREFIX
anymore, there is only the possibility to declare a Namespace with or without a
pre x. The complete SPARQLAS grammar can be found within the online
representation of the TwoUse project [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. By means of these simpli cations, the
example SPARQL query
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
PREFIX owl: &lt;http://www.w3.org/2002/07/owl#&gt;
PREFIX : &lt;http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#&gt;
SELECT DISTINCT ?x
WHERE {
:GermanWine owl:equivalentClass [
rdf:type owl:Class ;
owl:intersectionOf [
rdf:first :Wine ;
rdf:rest [
rdf:first [
rdf:type owl:Restriction ;
owl:onProperty :locatedIn ;
owl:hasValue ?x ] ;
rdf:rest rdf:nil ] ] ] }
can be reduced to this SPARQLAS query:
Namespace
        </p>
        <p>(=&lt;http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#&gt;)
Select
Where(EquivalentClasses(GermanWine And(Wine Has(locatedIn ?x))))</p>
        <sec id="sec-2-2-1">
          <title>2 http://www.eclipse.org/m2m/atl/</title>
          <p>Prologue From (Named)
SPARQL Pre x, Base yes
SPARQLAS Namespace no
Query Syntax</p>
          <p>RDF Triple
OWL-DL Expression
SPARQL
SPARQLAS</p>
          <p>Optional
yes
no</p>
          <p>Graph
yes
no</p>
          <p>Union
yes
no</p>
          <p>Filter Order Limit
SPARQL yes yes yes
SPARQLAS no no no
Table 1. Di erences between SPARQL and SPARQLAS constructs
2.3</p>
        </sec>
      </sec>
      <sec id="sec-2-3">
        <title>Model-to-Model Transformation</title>
        <p>
          The ATL model-to-model transformation can be divided into two parts, the
prologue and the query itself. The prologue consists of the Namespace declaration
and will be transformed to the equivalent PREFIX notation. During the query
part, the query form will be identi ed rst and transformed to accordingly. If it
is a Select query, the option DISTINCT will be set additionally. Then the main
contribution of each transformation starts, translating an OWL expression to its
equivalent RDF triple(s). These translations are based on speci c OWL to RDF
mapping rules [
          <xref ref-type="bibr" rid="ref12 ref13">12, 13</xref>
          ] and also nalize the transformation.
        </p>
        <p>This way the expressiveness of SPARQLAS queries is equivalent to SPARQL
queries using only RDF triples of the aforementioned mapping rules, which makes
SPARQLAS a subset of SPARQL. Further, SPARQLAS is even a proper subset
of SPARQL since not every SPARQL construct can be expressed by SPARQLAS,
e.g. FILTER or OPTIONAL conditions. These constructs are omitted with
regard to simplicity and readability. The complete list of di erences between
SPARQLAS and SPARQL can be found in Table 1.</p>
        <p>This speci c SPARQLAS to SPARQL transformation is implemented at
the TwoUse Toolkit3 and can be executed by opening the context menu on
a SPARQLAS le under the entry TwoUse ! Transform to SPARQL.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Application</title>
      <p>
        !
As a running application example, we present SPARQLAS for UML. Fig. 2
depicts a sample UML diagram according to the example query annotated with
stereotypes from the UML Pro le for RDF and UML Pro le for OWL [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Out
of this UML model, an ontology can be produced by another transformation
implemented at the TwoUse Toolkit. This ontology can then be queried using
SPARQLAS.
      </p>
      <p>We developed a context menu function on UML Operations via
SPARQLAS for UML Add SPARQLAS Query, which creates an</p>
      <sec id="sec-3-1">
        <title>3 http://code.google.com/p/twouse/</title>
        <p>empty SPARQLAS Select query with the given Namespace from the
UML pro le. This query le will be named after the convention
leName.className.operationName.sparqlas4uml, e.g. according to Fig. 2 it
will be named Wine.uml.GermanWine.getRegion.sparqlas4uml. Strictly
speaking this is a SPARQLAS4UML query, but it imports the whole SPARQLAS
language and so shall indicate that a SPARQLAS query is linked to an actual
UML le. Furthermore, this link between UML le and query will also be
expressed at the UML le itself as the EMF Resource will be added to the model
and so the query can be directly accessed through the UML model. This way it
is possible to automatically generate SPARQLAS queries from UML diagrams.
For this example the following empty Select query will be constructed:
Namespace</p>
        <p>( = &lt;http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#&gt; )
Select
Where ( )
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Evaluation</title>
      <p>At this point we would like to evaluate SPARQLAS against SPARQL. For this
purpose we examine 60 di erent test queries in two di erent ways with regard
to complexity. First, we compare the underlying meta model of SPARQLAS and
SPARQL. Due to EMFText every test query in textual syntax has an EMF
Resource representation, therefore we can count each instantiation of a meta
model class in these EMF Resources. To accelerate this counting process for
a total of 120 queries, we make use of another plug-in of the TwoUse Toolkit
called OWLizer, which can create ontologies out of Ecore based languages, e.g.
EMF Resources. These ontologies consist of the desired individuals that we need
to count and compare to achieve one indicator of complexity. After this
procedure, we obtain a result that implies a substantial reduction in complexity of
SPARQLAS queries against SPARQL queries. SPARQLAS queries reduce the
count of individuals in average by 82% with a minimum of 71% and a
maximum of 88% reduction with a standard deviation of 4%. The absolute numbers
of individuals range from 5-32 for SPARQLAS queries and 31-178 for SPARQL
queries.</p>
      <p>The second evaluation kind deals with the length of each query, but instead
of counting every single character, we compare the count of OWL expressions in
each SPARQLAS query to the count of RDF triples an equivalent SPARQL query
needs. This method ensures that the e ort of using OWL expressions rather
than RDF triples can be evaluated. The results of this procedure suggest that
the e orts may not be as predominant as with the other evaluation scenario, yet
the average reduction is by 50% with a maximum of 82% but having a standard
deviation of 31%. This high standard deviation is explained by the fact that
there are actual queries with no e ort, i.e. one OWL expression is equivalent to
one RDF triple, e.g. in case of ClassAssertion. However, there is only no e ort in
simple cases, more complex queries, especially nested queries, are showing more
and more reduction. The absolute numbers of OWL expressions resp. RDF triples
of our test queries range from 1-5 resp. from 1-23.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusion and Future Work</title>
      <p>In this paper we have presented the implementation of a novel query language for
OWL-DL ontologies, called SPARQL-DL Abstract Syntax (SPARQLAS), that
combines SPARQL and the OWL Functional-Style Syntax or a shortened version
of it. The possible application of two di erent syntaxes with the same
underlying meta model indicates that the speci c querying syntax is easily changeable.
This language can be employed just like a SPARQL query after the execution
of a model-to-model transformation from SPARQLAS to SPARQL. We have
demonstrated in a running application example, SPARQLAS for UML, how
SPARQLAS queries can be connected to UML models and performed on
ontologies created from these models by applying the UML Pro le for RDF and
UML Pro le for OWL. Further, we have shown by means of an evaluation that
SPARQLAS is e ectively reducing the complexity of a query on an OWL-DL
ontology, especially for nested queries.</p>
      <p>In our future work, we will enhance SPARQLAS to support the Manchester
Syntax and discuss the usage of other syntaxes as well. This way the user will be
able to choose his preference among these syntaxes. Additionally, we will create
a new application example to connect queries with Ecore models, SPARQLAS
for Ecore, since the OWLizer plug-in is capable of generating ontologies from
such Ecore models.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgments</title>
      <p>The work presented in this paper is supported by EU STReP-216691 MOST.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Prud'hommeaux</surname>
          </string-name>
          , E.,
          <string-name>
            <surname>Seaborne</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>SPARQL Query Language for RDF (</article-title>
          <year>15</year>
          .
          <fpage>01</fpage>
          .
          <year>2008</year>
          ) http://www.w3.org/TR/rdf-sparql-query/.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Motik</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Patel-Schneider</surname>
            ,
            <given-names>P.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parsia</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>OWL 2 Web Ontology Language Structural Speci cation</article-title>
          and
          <string-name>
            <surname>Functional-Style Syntax</surname>
          </string-name>
          (
          <volume>27</volume>
          .
          <fpage>10</fpage>
          .
          <year>2009</year>
          ) http://www. w3.org/TR/owl2-syntax/.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Bulka</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          : Pellet 2.1:
          <string-name>
            <given-names>Introducing</given-names>
            <surname>Terp</surname>
          </string-name>
          (
          <volume>01</volume>
          .
          <fpage>04</fpage>
          .
          <year>2010</year>
          ) http://clarkparsia.com/ weblog/2010/04/01/pellet21-terp/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Kubias</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schenk</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Staab</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pan</surname>
            ,
            <given-names>J.: OWL</given-names>
          </string-name>
          <string-name>
            <surname>SAIQL - An OWL DL Query</surname>
          </string-name>
          <article-title>Language for Ontology Extraction</article-title>
          .
          <source>In: OWLED 2007 OWL: Experiences and Directions Third International Workshop. (06</source>
          .
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Decraene</surname>
          </string-name>
          , D.: jOWL
          <string-name>
            <surname>- SPARQL-DL Test Suite</surname>
          </string-name>
          (
          <volume>03</volume>
          .
          <year>2009</year>
          ) http://jowl. ontologyonline.org/SPARQL-DL.
          <year>html</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. W3C: Wine Ontology (
          <volume>10</volume>
          .
          <fpage>02</fpage>
          .
          <year>2004</year>
          ) http://www.w3.org/TR/2004/ REC-owl-guide-20040210/wine.rdf.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Steinberg</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Budinsky</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Paternostro</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Merks</surname>
          </string-name>
          , E.: EMF:
          <article-title>Eclipse Modeling Framework</article-title>
          . 2nd ed.,
          <source>rev. and updated. edn. The eclipse series. Addison-Wesley</source>
          , Upper Saddle River, NJ (
          <year>2009</year>
          )
          <fpage>17</fpage>
          -
          <lpage>23</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8. International Organization for Standardization: ISO/IEC 14977:
          <year>1996</year>
          : Information technology - Syntactic metalanguage - Extended
          <string-name>
            <surname>BNF</surname>
          </string-name>
          (
          <year>1996</year>
          ) http://standards. iso.org/ittf/PubliclyAvailableStandards/index.html.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>EMFText: EMFText Concrete Syntax Zoo SPARQL</surname>
          </string-name>
          (
          <volume>20</volume>
          .
          <fpage>02</fpage>
          .
          <year>2010</year>
          ) http://www. emftext.org/index.php/EMFText_Concrete_Syntax_Zoo_SPARQL.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Sirin</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parsia</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>SPARQL-DL: SPARQL Query for OWL-DL</article-title>
          .
          <source>In: 3rd OWL: Experiences and Directions Workshop (OWLED2007)</source>
          . (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Schneider</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <source>SPARQLASGrammar (13.04</source>
          .
          <year>2010</year>
          ) http://code.google.com/p/ twouse/wiki/SPARQLASGrammar.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Patel-Schneider</surname>
            ,
            <given-names>P.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Horrocks</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>OWL Web Ontology Language Semantics and Abstract Syntax: Section 4</article-title>
          . Mapping to RDF Graphs (
          <volume>06</volume>
          .
          <fpage>02</fpage>
          .
          <year>2004</year>
          ) http://www. w3.org/TR/owl-semantics/mapping.html.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Patel-Schneider</surname>
            ,
            <given-names>P.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Motik</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>OWL 2 Web Ontology Language Mapping to</article-title>
          RDF Graphs (
          <volume>28</volume>
          .
          <fpage>10</fpage>
          .
          <year>2009</year>
          ) http://www.w3.org/TR/owl2-mapping
          <string-name>
            <surname>-</surname>
          </string-name>
          to-rdf/.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14. Object Management Group: Ontology De nition Metamodel (
          <volume>05</volume>
          .
          <year>2009</year>
          )
          <fpage>131</fpage>
          -
          <lpage>179</lpage>
          , http://www.omg.org/spec/ODM/1.0/.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>