<!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>Supporting SPARQL Update Queries in RDF-XML Integration</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Nikos Bikakis</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Chrisa Tsinaraki</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ioannis Stavrakantonakis</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stavros Christodoulakis</string-name>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>EU Joint Research Center</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>NTU Athens &amp; R.C. ATHENA</institution>
          ,
          <country country="GR">Greece</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>STI, University of Innsbruck</institution>
          ,
          <country country="AT">Austria</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>Technical University of Crete</institution>
          ,
          <country country="GR">Greece</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The Web of Data encourages organizations and companies to publish their data according to the Linked Data practices and offer SPARQL endpoints. On the other hand, the dominant standard for information exchange is XML. The SPARQL2XQuery Framework focuses on the automatic translation of SPARQL queries in XQuery expressions in order to access XML data across the Web. In this paper, we outline our ongoing work on supporting update queries in the RDF-XML integration scenario.</p>
      </abstract>
      <kwd-group>
        <kwd>SPARQL2XQuery</kwd>
        <kwd>SPARQL to XQuery</kwd>
        <kwd>XML Schema to OWL</kwd>
        <kwd>SPARQL update</kwd>
        <kwd>XQuery Update</kwd>
        <kwd>SPARQL 1</kwd>
        <kwd>1</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Introduction</p>
      <p>Translating SPARQL Update Queries to XQuery
This section describes the translation of SPARQL update operations into XQuery
expressions using the XQuery Update Facility. We present how similar methods and
algorithms previously developed in the SPARQL2XQuery Framework can be adopted
for the update operation translation. For instance, graph pattern and triple pattern
translation are also used in the update operation translation. Note that, due to space
limitations, some issues are presented in a simplified way in the rest of this section and several
details are omitted.</p>
      <p>Table 1 presents the SPARQL update operations and summarizes their translation in
XQuery. In particular, there are three main categories of SPARQL update operations a)
Delete Data; b) Insert Data; and c) Delete/Insert. For each update operation, a simplified
SPARQL syntax template is presented, as well as the corresponding XQuery
expressions. In SPARQL context, we assume the following sets, let tr be an RDF triple set, tp
a triple pattern set, trp a set of triples and/or triple patterns, and gp a graph pattern.
Additionally, in XQuery, we denote as xEW, xEI and xED the sets of XQuery expressions
(i.e., FLOWR expressions) that have resulted from the translation of the graph pattern
included in the Where, Insert and Delete SPARQL clauses, respectively. Let xE be a set
of XQuery expressions, xE($v1, $v2,… $vn) denote that xE are using (as input) the values
assigned to XQuery variables $v1, $v2,… $vn. Finally, xn denotes an XML fragment,
i.e., a set of XML nodes, and xp denotes an XPath expression.
(a) D}}Wtgerplpehteer{e{ (c) }DIetnrlspeeter{t{ (allr)eeetttu$$rdwnehldeetreeel__egtgepp:n=:=oxdxEeEsDW($$dwelheetere__ggpp)</p>
      <p>trp
}Where{ (c)
} gp tThreannstrlaatneslDaeteleItensWerhteWrehsearmeseaamse(aa)s, (b)</p>
      <p>
        In the following examples, we assume that an RDF source has been mapped to an XML
source. In particular, we assume the example presented in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], where an RDF and an
XML source describing persons and students have been mapped. Here, due to space
limitation, we just outline the RDF and XML concepts, as well as the mappings that are
involved in the following examples. In RDF, we have a class Student having several
datatype properties, i.e., FName, E-mail, Department, GivenName, etc. In XML, we have
an XML complex type Student_type, having an attribute SSN and several simple
elements, i.e., FirstName, Email, Dept, GivenName etc. Based on the XML structure, the
students’ elements appear in the \Persons\Student path. We assume that the Student class
has been mapped to the Student_type and the RDF datatype properties to the similar
XML elements.
      </p>
      <p>
        Delete Data. The Delete Data SPARQL operation removes a set of triples from RDF
graphs. This SPARQL operation can be translated in XQuery using the Delete Nodes
XQuery operation. Specifically, using the predefined mappings, the set of triples tr
defined in the SPARQL Delete Data clause is transformed (using a similar approach such
as the BGP2XQuery algorithm [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]) in a set of XPath expressions XP. For each xpi ∊ XP
an XQuery Delete Nodes operation is defined.
      </p>
      <p>In this example, two RDF triples are deleted from an RDF graph. In
addition to the mappings described above, we assume that the person
"http://rdf.gr/person1209" in RDF data has been mapped to the person
"/Persons/Student[.@SSN=1209]" in XML data.</p>
    </sec>
    <sec id="sec-2">
      <title>SPARQL Delete Data query  Translated XQuery query</title>
      <p>Delete data{ delete nodes
collection("http://xml.gr")/Persons/Stu&lt;http://rdf.gr/person1209&gt; ns: FName "John" . dent[.@SSN=1209]/FirstName[.= "John"]
&lt;http://rdf.gr/person1209&gt; ns:E-mail "john@smith.com". delete nodes
collection("http://xml.gr")/Persons/Stu} dent[.@SSN=1209]/Email[.= "John@smith.com"]
Insert Data. The Insert Data SPARQL operation, adds a set of new triples in RDF
graphs. This SPARQL operation can be translated in XQuery using the Insert Nodes
XQuery operation. In the Insert Data translation, the set of triples tr defined in SPARQL
are transformed into XML node sets xni, using the predefined mappings. In particular,
a set of Let XQuery clauses is used to build the XML nodes and define the appropriate
node nesting and grouping. Then, the location of the XML node insertion can be easily
determined considering the triples and the mappings. Finally, the constructed nodes are
inserted in their location of insertion using the XQuery Insert nodes clause.</p>
      <p>In this example, the RDF triples deleted in the previous example are
reinserted in the RDF graph.</p>
    </sec>
    <sec id="sec-3">
      <title>SPARQL Insert Data query  Translated XQuery query</title>
      <p>
        Insert data{ let $n1 := &lt;FirstName&gt;John&lt;/FirstName&gt;
&lt;http://rdf.gr/person1209&gt; ns:FName "John" . let $n2 := &lt;Email&gt;john@smith.com&lt;/Email&gt;
&lt;http://rdf.gr/person1209&gt; ns:E-mail "john@smith.com". let $data1 := ($n1, $n2)
} let $insert_location1 :=
collection("http://xml.gr")/Persons/Student[.@SSN=1209]
return insert nodes $data1 into $insert_location1
Insert / Delete. The Delete/Insert SPARQL operations are used to remove and/or add a
set of triples from/to RDF graphs, using the bindings that resulted from the evaluation
of the graph pattern defined in the Where clause. According to the SPARQL 1.1
semantics, the Where clause is the first one that is evaluated. Then, the Delete/Insert clause is
applied over the produced results. Especially, in case, that both Delete and Insert
operations exist, the deletion is performed before the insertion, and the Where clause is
evaluated once. The Delete and the Insert SPARQL operations can be translated to XQuery
using the Delete Nodes and Insert Nodes operations, respectively. In brief, initially the
graph pattern used in the Where clause is translated to XQuery expressions xEW
(similarly as in the GP2XQuery algorithm [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]). Then, the graph pattern used in the
Delete/Insert clause is translated to XQuery expressions xED/xEI (as it is also in the BGP2XQuery
algorithm [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]) using also the bindings that resulted from the evaluation of xEW.
      </p>
      <p>In this example, the Where clause selects all the students studying in a
computer science (CS) department. Then, the Delete clause deletes all the triples that
match with its triple patterns, using the ?student bindings determined from the Where
clause. In particular, from all the retrieved students (i.e., CS students), the students
which have as first name the name "John" should be deleted.</p>
    </sec>
    <sec id="sec-4">
      <title>SPARQL Delete query</title>
      <p>Delete{</p>
      <p>?student ns:FName "John" .
}Where{
?student ns:Department "CS" .
</p>
    </sec>
    <sec id="sec-5">
      <title>Translated XQuery query</title>
      <p>let $where_gp := collection("http://xml.gr")/Persons/Student[./Dept="CS"]
let $delete_gp := $where_gp[./FirstName="John"]
return delete nodes $delete_gp
}</p>
      <p>In this example, the Where clause selects all the students studying in a CS
department, as well as their first names. Then, the Insert clause creates new triples
according to its triple patterns, using the ?student and ?name bindings determined
from the Where clause. In particular, a new triple having as predicate “ns:GivenName”
and as object the first name of the ?student, is inserted for each ?student.</p>
    </sec>
    <sec id="sec-6">
      <title>SPARQL Insert query</title>
      <p>Insert{</p>
      <p>?student ns:GivenName ?name .
}Where{
?student ns:FName ?name .
?student ns:Department "CS" .
</p>
    </sec>
    <sec id="sec-7">
      <title>Translated XQuery query</title>
      <p>let $where_gp := collection(“http://xml.gr”)/Persons/Student[./Dept="CS"]
let $insert_location1 := $where_gp
for $it1 in $insert_location1
let $insert_gp1 := &lt;GivenName&gt;{fn:string($it1/FirstName)}&lt;/GivenName&gt;
return insert nodes $insert_gp1 into $it1</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Eisenberg</surname>
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kanza</surname>
            <given-names>Y.</given-names>
          </string-name>
          :
          <article-title>"D2RQ/update: updating relational data via virtual RDF"</article-title>
          .
          <source>In WWW 2012</source>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Hert</surname>
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reif</surname>
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gall H. C.</surname>
          </string-name>
          <article-title>: "Updating relational data via SPARQL/update"</article-title>
          .
          <source>In EDBT/ICDT Workshops</source>
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Ali</surname>
            <given-names>M.I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lopes</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Friel</surname>
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mileo</surname>
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>"Update Semantics for Interoperability among XML, RDF and RDB"</article-title>
          .
          <source>In APWeb 2013</source>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Bischof</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Decker</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Krennwallner</surname>
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lopes</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Polleres</surname>
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>"Mapping between RDF and XML with XSPARQL"</article-title>
          .
          <source>J. Data Semantics</source>
          <volume>1</volume>
          (
          <issue>3</issue>
          ), (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Bikakis</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tsinaraki</surname>
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gioldasis</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stavrakantonakis</surname>
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Christodoulakis</surname>
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>"The XML and Semantic Web Worlds: Technologies, Interoperability and Integration. A survey of the State of the Art"</article-title>
          .
          <source>In Semantic Hyper/Multi-media Adaptation: Schemes and Applications</source>
          , Springer 2013
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Bikakis</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tsinaraki</surname>
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stavrakantonakis</surname>
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gioldasis</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Christodoulakis</surname>
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>"The SPARQL2XQuery Interoperability Framework"</article-title>
          .
          <source>World Wide Web Journal (WWWJ)</source>
          ,
          <year>2014</year>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>