<!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>On the Semantics of Updates in a Functional Language</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, Faculty of Electrical Engineering, Czech Technical University in Prague</institution>
          ,
          <addr-line>Prague, Karlovo na ́m. 13, 121 35</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Proceedings of the Spring Young Researcher's Colloquium on Database and Information Systems</institution>
          ,
          <addr-line>Saint-Petersburg, Russia, 2008</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>Issues related to updating data in native XML database systems are studied extensively nowadays. In this work we consider a problem of updating typed XML documents having their schema described by a Document Type Definition (DTD) without breaking their validity and with ensured transaction consistency. We present a way how to express constructs available in DTD by using a functional framework and propose algorithms for performing insert, replace and delete operations. This solution is an intermediate step we need for our ongoing research - formal comparison of XQuery and XML-λ. ∗ I would like to thank to Prof. Pokorny´ for his patience and provisioning of many helpful hints for my research.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Fundamental work we continue to work on is Pokorny´ ’s
proposal of a functional framework for modeling and
querying XML – XML-λ [
        <xref ref-type="bibr" rid="ref15 ref16">15, 16</xref>
        ]. The main idea therein
is to use simply typed λ-calculus adherent to a
DTDbased type system for querying XML data. Over time we
identified a need for extending the language with support
of data modification operations. Our aim is to develop
an approach similar to the SQL language for relational
databases, i.e. to have an ability both to query and
update underlying data within one formal apparatus.
      </p>
      <p>
        This work directly continues in the topic that we have
opened in [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]; in this text we clarify more the
concept of the framework by showing its relationship to the
W3C data model, reformulate proposed algorithms and
we also add some improvements in formal description of
the solution.
      </p>
      <p>Nevertheless, our primary motivation is not to
develop a totally new sort of an XML update language but
rather to propose an update extension that allows us to go
on with our planned research in the future – comparison
of properties of XQuery and XML-λ and evaluation of
potential mutual transformations of queries written in
respective languages. We see the benefit of this paper
par2</p>
    </sec>
    <sec id="sec-2">
      <title>Languages for Updating XML</title>
      <p>By the term updating XML we mean the ability of a
language to perform modifications (insert, replace and
delete operations) over an XML document or a
collection of XML documents.</p>
      <p>
        Since the creation of the XML in 1998, there have
been many efforts to develop various data models and
query languages for databases of XML data. Multiple
approaches for indexing and query optimizations have
been invented. On the other hand, the problem of
updating XML gains more interest in few past years. Yet
there seems to be not a complete solution for this
problem. Existing papers dealing with updating XML are
mostly related to XQuery [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Lehti [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] proposes an
extension to XQuery that allows all update operations but
does not care about the validity of the documents.
Tatarinov et al. [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ] also extend XQuery syntax with insert,
update and delete operations and show the implementation
of storage in a relational database system. Benedikt et
al. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] and Sur et al. [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ] deal in deep with the semantics
of updates in XQuery. In the W3C XML Query
Working Group is the need for having updates in the language
also considered as one of the most important topics in its
further development [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. As a result, the XQuery Update
Facility has been proposed [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        For the sake of completeness we should not omit
XUpdate [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] – a relatively old proposal that takes a
different way. It uses XML-based syntax for describing
update operations. This specification is less formal than
those previous but it is often used in practice.
      </p>
      <p>
        Another research field is represented by XDuce [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]
and its successor CDuce [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] that use also a type system
based approach for pattern matching and manipulation of
XML data.
      </p>
      <p>Considering previous works we can deduce that there
are common types of operations for performing
modifications that are to be embedded in a language – delete,
replace, insert-before, insert-after or insert-as-child. This
seems to be a sufficient base for ongoing work. None of
those proposals but deals in detail with the problem of
updating typed data and hence it makes sense to put
effort and study this problem.
3</p>
      <sec id="sec-2-1">
        <title>XML-λ Framework</title>
        <p>
          XML-λ is a proposal published by Pokorny´ [
          <xref ref-type="bibr" rid="ref15 ref16">15, 16</xref>
          ]. In
contrast to W3C specifications it uses a functional data
model instead of tree- or graph-oriented model. The
primary motivation was to see XML documents as a
database that conforms to an XML schema (defined, for
example, by DTD) and to gain a possibility to use a
functional language, particularly a simply typed λ-calculus,
as a query language for such database.
        </p>
        <p>
          Except of the original proposal, that defines its formal
base and shows its usage primarily as a query language
for XML, there is a consecutive work that introduces
updates into the language available in [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ].
        </p>
        <p>Here, we focus primarily on extending and improving
the update part of the framework. Basic facts about the
framework are repeated in following sections rather for
convenience.
3.1</p>
        <sec id="sec-2-1-1">
          <title>Basic Terms</title>
          <p>In XML-λ there are three important components related
to its type system: element types, element objects and
elements. We can imagine these components as the data
dictionary in relational database systems. Note also
Figure 1 for relationships of basic terms between W3C
standards and the XML-λ Framework.</p>
          <p>Element types are derived from a particular DTD and
in our scenario they cannot be changed – we do not
allow any schema changes but only data modifications. For
each element defined in the DTD there exists exactly
one element type in the set of all available element types
(called TE).</p>
          <p>Consequently, we denote E as a set of abstract
elements. Set members are of element types. Note that
(from definition) E is an infinite set.</p>
          <p>Element objects1 are basically functions of type either
E → String or E → (E × . . . × E). Application of
1We denote the element object of type t ∈ TE as t-object
these functions to an abstract element allows access to
element’s content. Elements are, informally, values of
element objects, i.e. of functions. For each t ∈ TE there
exists a corresponding t-object.</p>
          <p>For convenience, we add a ”nullary function” (also
known as 0-ary function) into our model. This function
returns a set of all abstract elements of a given element
type from an XML document.</p>
          <p>Finally, we can say that in XML-λ the instance of an
XML document is represented by a subset of E and set
of respective t-objects.</p>
          <p>For readers familiar with W3C terminology, there is a
comparison of related terms in both environments shown
in Table 1.
3.2</p>
        </sec>
        <sec id="sec-2-1-2">
          <title>XML-λ Example</title>
          <p>This section shows an example of using the XML-λ
Framework in a real example with detailed description.
Let us consider an example DTD shown in Figure 2.
&lt;!ELEMENT bib
&lt;!ELEMENT book
&lt;!ELEMENT author
&lt;!ELEMENT title
&lt;!ELEMENT last
&lt;!ELEMENT first
&lt;!ELEMENT price
(book* )&gt;
(title, author+, price )&gt;</p>
          <p>(last, first )&gt;
(#PCDATA )&gt;
(#PCDATA )&gt;
(#PCDATA )&gt;
(#PCDATA )&gt;</p>
          <p>For given schema we obtain element types as follows:
BIB : BOOK∗,
BOOK : (T IT LE, AU T HOR+, P RICE),
AU T HOR : (LAST , F IRST ),
LAST : String,
F IRST : String,
T IT LE : String,
P RICE : String.</p>
          <p>Then, we define functional types – designated as
t-objects:
BIB : E → 2E,
BOOK : E → (E × 2E × E),
AU T HOR : E → (E × E),
T IT LE : E → String,
LAST : E → String,
F IRST : E → String,
P RICE : E → String.</p>
          <p>These types are the cornerstone for manipulation with
typed data from XML documents as shown in the list of
semantic functions (see Table 2).</p>
          <p>Having look at DTD in Figure 2 and sample
data in Figure 3 we can obviously see that there
are 7 abstract elements (members of E0 ⊂ E).
Now, for instance, the title-object is defined
exactly for one abstract element (the one gained from
&lt;title&gt;TCP/IP Illustrated&lt;/title&gt; element and
for this abstract element it returns a string value ”TCP/IP
Illustrated”.</p>
        </sec>
        <sec id="sec-2-1-3">
          <title>Data Format Data Model Constraints XML Data Instance Query Languages</title>
          <p>XML 1.0
Document Type Definition (DTD)
DOM - A tree instance
XPath, XQuery, XSLT
XML 1.0
Types in TE derived from DTD
Set of abstract elements – E, definition of t-objects
Simply typed lambda calculus
&lt;bib&gt;
&lt;book&gt;
&lt;title&gt;TCP/IP Illustrated&lt;/title&gt;
&lt;author&gt;
&lt;last&gt;Stevens&lt;/last&gt;
&lt;first&gt;W.&lt;/first&gt;
&lt;/author&gt;
&lt;price&gt;65.95&lt;/price&gt;
&lt;/book&gt;
...
&lt;/bib&gt;</p>
          <p>
            Following example query returns all books with
specified price
lambda b (/book(b) and b/price = "65.95" )
Evaluation of this query with respect to semantics
described in [
            <xref ref-type="bibr" rid="ref19">19</xref>
            ] takes place in following way:
1. First, the binding of free variable b is evaluated
(/book(b)), i.e. nullary function returns a set of
all abstract elements of element type BOOK).
2. For each item in b the application of BOOK-object
element (note, it is a function) is performed
BOOK : E → (E × . . . × E)
and this operation returns an n-tuple.
3. Projection by name price returns then item(s) of
type PRICE (there is just one). Application of
function P RICE : E → P RICE : String returns a
string value of the price element that is compared
with literal ”65.95”. Non-matching item is skipped,
otherwise the content of b is serialized to output.
4. Steps 2.-3. are repeated for all items found in Step 1.
          </p>
          <p>For readers familiar with XQuery, here is the same
query expressed in XQuery syntax:
{
}
for $b in doc("bib.xml")/bib/book
where $b/price = "65.95"
return {$b}</p>
          <p>Expected output is shown in Figure 4.
4</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Updating XML Documents</title>
      <p>This section covers the process of updating data in an
existing XML data store. Thus, we do not update XML
schema of these documents but their content only. It is a
typical database life cycle – the database schema remains
&lt;book&gt;
&lt;title&gt;TCP/IP Illustrated&lt;/title&gt;
&lt;author&gt;
&lt;last&gt;Stevens&lt;/last&gt;
&lt;first&gt;W.&lt;/first&gt;
&lt;/author&gt;
&lt;price&gt;65.95&lt;/price&gt;
&lt;/book&gt;
stable but the data is changing in time. In our (query
and update) language there is no way how to construct
new documents yet – sometimes this approach is called
”incremental update”. In other words we can change
the structure of the input document (w.r.t the DTD) by
a given XML-λ update statement but cannot e.g. create
a set of new XML files.
We can describe the whole operation of updating an
XML document rather on a physical level as (1)
retrieving its content from database, (2) performing update, (3)
storing document back to database. This paper deals with
the second part of the process. Viewed from closer look
in more detailed pieces it is (a) localization of point in
data model where the change will take place, (b)
validation of requested operation, (c) execution of the
update operation. These steps are shown more from the
semantical point of view, in implementation it is usually
not necessary to retrieve complete XML document from
database into memory but we can manipulate only with
a part of its content needful for update.</p>
      <p>There are two options when to perform data
validation – before or after an update. The XQuery Update
Facility proposal uses optional post-update revalidation; in
our approach we focus more on doing pre-update checks.
Our goal is to detect the maximum number of possible
conflicts during compilation of the update statement and
potentially raise a static error. Unfortunately, not in all
cases is the information from data model enough for
validation and, therefore, it is necessary to perform
validation with respect to particular data stored in the data
store. We discuss this issue later in Section 5.
Regardless the scenario, the processed XML document is a valid
instance in the type system both before and after update.
1. Elements constraints - Specify the type of element
content. The possible value is one of EMPTY, ANY,
MIXED or ELEMENT_CONTENT,
2. Structure constraints - The occurrence of elements
in a content model. Options are exactly-one,
zeroor-one, zero-or-more, one-or-more,
3. Attributes constraints - Each attribute can have one
of #REQUIRED, #IMPLIED, #FIXED, ID, IDREF(S)
options assigned.</p>
      <p>Each update operation can or cannot be affected by
any construct from the particular DTD. Note that element
content type ANY cannot be used in XML-λ, because of
the framework’s type system nature.
4.3</p>
      <sec id="sec-3-1">
        <title>Concept of Updates in XML-λ</title>
        <p>
          This section covers the basic concept of updates in the
XML-λ Framework. It initially had not have any update
facility. We had to extend it with features allowing us to
check constraints available in DTD. The idea of updates
has been opened in [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ] but here we focus just on the
main idea.
        </p>
        <p>As already outlined in Section 3.1, there are three
crucial components related to the type system - element
types, element objects and abstract elements. Element
types are derived from a particular DTD and in our
scenario they cannot be changed.</p>
        <p>Elements are, informally, values of element objects,
i.e. of functions. Thus, by updating an XML document
in XML-λ we modify the actual domains of these
functions (subsets of E) and element objects affected by
required update operation (insert, delete, replace).</p>
        <p>Before of that, we have to validate requested
operation. For now let us consider constraints described by
a DTD but in the outlook there are more options which
standards we plan to use as well (e.g. XML Schema).
Therefore we design our solution keeping this possibility
in mind.</p>
        <p>Sections 5.3 - 5.5 discuss the semantics of delete,
insert and replace operations in detail.
4.4</p>
      </sec>
      <sec id="sec-3-2">
        <title>Concurrency Support</title>
        <p>
          One disadvantage of the solution proposed in [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ] is the
lack of transaction support [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. In this work we assume
the existence of a transaction manager that can control
(i.e. lock, unlock, suspend or abort) user activities.
Currently we carry out a parallel research on using the
taDOM locking protocol [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] together with XML-λ (there
is a recent paper that introduces our first proposal of the
transactional behavior for XML-λ in [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ]).
        </p>
        <p>For now, we can consider that a transaction manager
locks the complete part of XML data that can be modified
during the update operation (in the worst case even the
whole XML document). It is a significant performance
issue but for purpose of this paper it is not fundamental.</p>
        <p>Thus, at the beginning of suggested algorithms we
only ask for locking of a specific part of processed XML
document and keep all concurency-related worries and
issues on the ”virtual” transaction manager.
5</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Analysis and</title>
      <p>XML-λ</p>
    </sec>
    <sec id="sec-5">
      <title>Design of</title>
    </sec>
    <sec id="sec-6">
      <title>Updates in</title>
      <p>and then semantics of all supported update operations –
insert, delete and replace.
In this paper we base our work on constraints available
in DTDs. The goal here is to describe these limitations
in general as much as possible for eventual future
extensions. Validating update operations is a problem very
closely related to the problem of validating a complete
XML instance. This process, however, can be for
extensive documents very time consuming.</p>
      <p>In our approach we propose two sets of types and
algorithms for validation for each update operation.
Mentioned sets are constructed and initiated during analysis
of given DTD and contain element types from TE . Due
to the fact that we do not allow schema changes, they are
stable in time.</p>
      <p>1. Timmutable. Abstract elements of types from this
set and respective t-objects are not changeable in
our data model. In terms of DTD these types are
associated with DTD types which content cannot be
modified, i.e. attributes declared as #FIXED and
element types with EMPTY content model.
2. Tmandatory. Abstract elements of types from this
set and respective t-objects are not modifiable (must
not be removed) in our data model. In terms of
DTD this set contains types associated with
attribute types with #REQUIRED declaration and
element types for those types Ti iff all occurrences of
Ti in given DTD are exactly-one.</p>
      <p>These sets we use in our semantics for particular
update operations. For future work we can also
consider sets Treferencing and Treferenced of types
associated with attributes declared in given DTD as IDREF or
IDREFS and for attributes declared as ID respectively. In
following text we use number of functions with informal
meaning as summarized in Table 2.
5.2</p>
      <p>General Notes to Proposed Algorithms
Following sections contain particular algorithms for data
modification shown in detail. The most important of
them – Delete and Insert – follow the same structure.
First, they check (optionally) the validity of the operation
and if there is no conflict with the type system definition
they break down the modification into a list of primitive
operations (stored in a structure also known as the
”Pending Update List”). This list represents hence the result of
these algorithms. Note that the Replace algorithm
combines aforesaid Delete and Insert with within. The items
inside the list are pairs (e, op), where e ∈ E is an
abstract element and op ∈ {DELET E, IN SERT } is the
operation to be carried out.</p>
      <p>The output pending update list, that represents the
result of each update algorithm, is then passed to the
ProcessPendingList algorithm. This algorithm then executes
all primitive changes requested.
5.3</p>
      <sec id="sec-6-1">
        <title>Delete</title>
        <p>In this section we describe two parts of the update
process – general concept of validation we use in XML-λ
Formally, we decompose the process into two parts – a
function checkDelete that is used for checking whether
parent(e)
typeOf(e)
cardMin(e),cardMax(e)
alterTObjectDel(e, t),
alterTObjectIns(e, t)
isSubtype(t1, t2)
canSubstitute(t1, t2)
isElementary(t)
application(e, t)
projection(n-tuple, t)
count(n-tuple)
For an e ∈ E returns its parent abstract element. An abstract element can have at most one
associated ”parent” element. When considering E as infinite set of abstract elements, most of
them have no parent associated.</p>
        <p>For an e ∈ E returns its element type (see Section 3.1).</p>
        <p>Return minimal (or maximal, respectively) cardinality of an abstract element’s type in a particular
data model instance.</p>
        <p>Alters the t-object for given e ∈ E. Regarding the fact that t-objects are functions these semantic
functions change the domain of given t-object and thus associations among abstract elements.
Basically, alterTObjectDel removes the abstract element e from domain of the t-object and
alterTObjectIns adds the abstract element e into the domain.</p>
        <p>Describes a relation between element types t1 and t2. Returns true iff the result of
application(e, t2) for an e ∈ E can return an n-tuple containing an abstract element of type t1 (at
any position).</p>
        <p>Returns true iff an abstract element e1 of type t1 can replace an element e2 of type t2 without
breaking document’s validity. It is utilized in the Replace algorithm.</p>
        <p>Returns true iff t is an elementary element type.</p>
        <p>Executes an application of t-object to the e element. In general it returns an n-tuple from
Cartesian product of (E × . . . × E).</p>
        <p>Note that the application function serves for diving in the ”content” of an element.
Retrieves all elements of type t from given n-tuple.</p>
        <p>Returns number of elements in an n-tuple.
an abstract element can be deleted and a complete
algorithm Delete that accomplishes the operation completely:
Function: checkDelete;
Input: E - set of abstract elements</p>
        <p>e - an abstract element to be deleted
Output: returns true - deletion is allowed,</p>
        <p>false - deletion is denied
begin
let t = typeOf (e);
if ((t ∈ Tmandatory) or (t ∈ Timmutable)) then</p>
        <p>return false;
if ((cardM in(e) = 0) and (cardM ax(e) = ∞)) then</p>
        <p>return true;
if ((cardM in(e) ≥ 1) and
(count(application(parent(e), t)) &gt; 1)) then
return false;
return true;
end</p>
      </sec>
      <sec id="sec-6-2">
        <title>Algorithm: Delete;</title>
        <p>Input: E - set of abstract elements
e - an abstract element to be deleted
checkV alidity - a boolean flag. Enables or
disables validity check. Default is true.
trans - a new transaction
pList - a list of currently pending update</p>
        <p>operations
Output: returns true - delete is allowed,</p>
        <p>false - delete failed
pList - updated list of pending operations
begin
/* Lock the data being deleted */
trans.lockRequest(DELET E N ODE, e);
/* Check type constraints - if requested */
if (checkV alidity) then
if (not checkDelete(E, e)) then return false;
let S = new Stack(); S.push(e);
while (tmp = S.pop()) do
let t = typeOf (tmp);
let nt = application(tmp, t);
For i = 1 to count(nt)
let etmp = nt[i];
let ttmp = typeOf (etmp);
/* Elementary element types are added into
the pending delete list */
if (isElementary(ttmp)) then</p>
        <p>pList.add(etmp, DELET E))
else
/* Complex element types are stored for</p>
        <p>next iterations */</p>
        <p>S.push(etmp);
next;
end
/* Add the initial abstract element to pending list */
pList.add(tmp, DELET E);
/* Deletion is finished */
return true;
end
5.4</p>
      </sec>
      <sec id="sec-6-3">
        <title>Insert</title>
        <p>As for the Delete algorithm, we propose two parts of the
insert process – function checkInsert that validates
insertion of given abstract element and Insert algorithm that
implements the operation in whole.</p>
        <p>Function: checkInsert;
Input: E - set of abstract elements
e1 - an abstract element to be inserted,
e2 - an abstract element to be associated with e1
as its parent abstract element,
Output: returns true - insertion is allowed,</p>
        <p>false - insertion is denied
begin
let t = typeOf (e2);
if (t ∈ Timmutable) then return false;
/* Add the initial abstract element to pending list */
pList.add(e1, IN SERT )
/* Insert is finished */
return true;
end
/*Traversing through all ”sibling” abstract elements*/
let nt = application(tmp, t);
for i = 1 to count(nt)
let etmp = nt[i];
let ttmp = typeOf (etmp);
if (isSubtype(typeOf (e1), ttmp)) then
if (cardM ax(etmp) &gt; 1) then return true;
if ((cardM in(e) = 0) and
(cardM ax(etmp = ∞)) and
/* Lock the data being inserted */
trans.lockRequest(IN SERT N ODE, e1);
if (checkV alidity) then</p>
        <p>if not checkInsert(E, e1, e2) then return false;
let S = new Stack(); S.push(e);
while (tmp = S.pop()) do
let t = typeOf (tmp);
let nt = application(tmp, t);
For i = 1 to count(nt)
let etmp = nt[i];
let ttmp = typeOf (etmp);
/* Elementary element types are inserted</p>
        <p>into pending list */
if (isElementary(ttmp)) then</p>
        <p>pList.add(etmp, IN SERT )
else
/* Complex element types are stored for</p>
        <p>next iterations */</p>
        <p>S.push(etmp);
next;
end
type tnew (for example, for t1 = (a|b), t2 = a ⇒
canSubstitute(t1, t2) = true).</p>
        <p>Note that we turn off the type validation for
particular Delete and Insert calls. Type validity is already
checked at the beginning of the algorithm.</p>
      </sec>
      <sec id="sec-6-4">
        <title>Algorithm: Replace;</title>
        <p>Input: E - set of abstract elements
e1 - an abstract element to be replaced,
e2 - an abstract element used as the substitution of e1
trans - a new transaction,
pList - a list of currently pending update operations
Output: returns true - replace is allowed,</p>
        <p>false - replace failed
pList - list of pending update operations
begin
/* It must be allowed to replace e1 with e2 */
if not (canSubstitute(typeOf (e1), typeOf (e2)) then
return false;
let etmp = parent(e1);
if not Delete(E, e1, trans, f alse, pList) then
return false;
if not Insert(E, e2, etmp, trans, f alse, pList) then
return false;
end
/* Replace is finished */
return true;
5.6</p>
      </sec>
      <sec id="sec-6-5">
        <title>Pending Update List Processing</title>
        <p>The Delete, Insert and Replace algorithms introduced in
previous sections transform high-level manipulation
operations into a sequential list of primitives that is stored
in the structure called Pending Update List – here it is
denoted as variable pList. This list is to be processed by
the database engine at the end of each high-level
operation in cooperation with the transaction manager.</p>
        <p>Following algorithm describes the operation more
formally.</p>
        <p>Algorithm: ProcessPendingList;
Input: E - set of abstract elements
t-objects associated with affected abstract elements
pList - a list of currently pending update operations
Output: pList - an empty pending list,
begin</p>
        <p>E - (potentially modified) set of abstract elements,
t-objects - (potentially modified) t-objects
while (pList.hasN ext()) do
let tmp = pList.next(); pList.remove();
let e = tmp.getItem();
let t = typeOf (parent(e));
let op = tmp.getOperation();
if (op == IN SERT ) then
let E = E ∪ e;
alterT ObjectIns(e, t);
else / ∗ DELET E ∗ /
let E = E \ e;
alterT ObjectDel(e, t);
next;
end
/* Pending List is now empty */
end
5.7</p>
      </sec>
      <sec id="sec-6-6">
        <title>Query Language Impact</title>
        <p>
          Considering the XML-λ Query Language as specified
in [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ], we have changed and extended the semantics
of all update operations. The syntax of the language
remains the same.
6
        </p>
        <sec id="sec-6-6-1">
          <title>XML-λ’s Future Exploitation</title>
          <p>By the extensions proposed in this paper we obtain a
framework suitable for both querying and updating XML
data. With respect to its original idea there is a number
of potential applications of the framework. Let us sketch
three possible ways how to continue with its
development:
1. further expand its query and update capabilities,
2. use it for integration of heterogeneous data sources,
3. use the XML-λ’s formal apparatus for description
of XQuery semantics.</p>
          <p>For each option there is still a lot of work ahead. To
get a complete query framework we have to finalize an
issue with references within documents (IDs and IDREFS).
This is only a technical problem of introducing new types
and formalizing the algorithm to be executed to keep the
documents consistent and valid. Let us also note another
questionable area that is not covered in this paper and
thus the dependencies of multiple update operations in
one ”query” statement. This issue deals with
transactional processing and optimizing multiple update
primitives’ execution.</p>
          <p>This option is also questionable because of wide
acceptance of XQuery as the de-facto theoretical and
industrial standard in the area of query languages for XML. At
least, the research here will require extensive enthusiasm
and sufficient resources.</p>
          <p>
            Integration of heterogeneous data sources (as outlined
in [
            <xref ref-type="bibr" rid="ref15">15</xref>
            ]) is a practical application of the solution we have
presented. With respect to the universal type system
construction it is possible to use various data models (not
only DTD or XML Schema for XML) but for instance
the relational or object data model as well.
          </p>
          <p>
            The third option for ongoing research is using the
framework for description of XQuery’s semantics. This
is probably the most interesting research branch from the
theoretical point of view. It generally means that we will
be able to express any XQuery statement with a
corresponding XML-λ alternative. This idea represents a
theoretical research related to formal methods and
compilers. In this case the framework is going to be used as a
tool for transformation of queries between various query
and update languages. In addition, we can use this tool
for evaluation of XQuery queries within our prototype
of a native XML database system ExDB [
            <xref ref-type="bibr" rid="ref12">12</xref>
            ] based on
XML-λ.
          </p>
          <p>Another feasible challenge for future work is
redefinition of the type system by replacement of DTD types by
types available in XML Schema or in RELAX NG. This
means restructuralization of the type systems Treg and
TE and redevelopment of the idea of constraint sets. This
research would demonstrate that the concept of
functional framework is not strictly bound to DTD but is more
general as we declare.
7</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>Conclusion</title>
      <p>We have shown a proposal for updating typed XML data
constrained by a Document Type Definition. We build
on a functional framework for querying XML that can
utilize concept of DTD constraints in its type system TE.
Main part of the paper discusses the idea of extending the
framework with update operations with accent to keep
the documents always valid. By enriching the XML-λ
query language with modification operations - inserts,
deletes and replacements - we obtain a language suitable
both for querying and updating XML documents.</p>
      <p>Further work and research directions outlined in
Section 6 lead to onward framework extensions – either
improving its query capabilities, using it for integration of
heterogeneous data or utilizing the framework for
description of semantics of various query languages.</p>
      <p>In any case the work presented in this paper creates
sufficient base for extensive future work.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Benedikt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bonifati</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Flesca</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Vyas</surname>
          </string-name>
          .
          <article-title>Adding updates to XQuery: Semantics, optimization, and static analysis</article-title>
          .
          <source>In XIME-P</source>
          <year>2005</year>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>V.</given-names>
            <surname>Benzaken</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Castagna, and</article-title>
          <string-name>
            <surname>A. Frisch.</surname>
          </string-name>
          <article-title>CDuce: An XML-centric general purpose language</article-title>
          .
          <source>In Proceedings of ICFP</source>
          <year>2003</year>
          , Uppsala, Sweden,
          <year>August 2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>S.</given-names>
            <surname>Boag</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Chamberlin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. F.</given-names>
            <surname>Ferna</surname>
          </string-name>
          ´ndez,
          <string-name>
            <given-names>D.</given-names>
            <surname>Florescu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Robie</surname>
          </string-name>
          , and J.
          <source>Sime´on. XQuery 1</source>
          .0:
          <string-name>
            <surname>An</surname>
            <given-names>XML</given-names>
          </string-name>
          <string-name>
            <surname>Query Language</surname>
          </string-name>
          ,
          <year>January 2007</year>
          . http://www.w3.org/TR/xquery/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>T.</given-names>
            <surname>Bray</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Paoli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. M.</given-names>
            <surname>Sperberg-McQueen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Maler</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Yergeau</surname>
          </string-name>
          .
          <article-title>Extensible markup language (XML) 1.0 (fourth edition)</article-title>
          ,
          <year>August 2006</year>
          . http://www.w3.org/TR/2006/REC-xml-
          <volume>20060816</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>D.</given-names>
            <surname>Chamberlin</surname>
          </string-name>
          . XQuery:
          <article-title>Where do we go from here</article-title>
          ? In XIME-P
          <year>2006</year>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>D.</given-names>
            <surname>Chamberlin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Florescu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Melton</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Robie</surname>
          </string-name>
          , and J. Sime´on.
          <source>XQuery Update Facility 1.0</source>
          ,
          <string-name>
            <surname>March</surname>
          </string-name>
          <year>2008</year>
          . http://www.w3.org/TR/2008/CRxquery-update-
          <volume>10</volume>
          -20080314/.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>C. J.</given-names>
            <surname>Date</surname>
          </string-name>
          .
          <article-title>An Introduction to Database Systems, 6th Edition</article-title>
          . Addison-Wesley,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>M. P.</given-names>
            <surname>Haustein</surname>
          </string-name>
          and
          <string-name>
            <given-names>T.</given-names>
            <surname>Ha</surname>
          </string-name>
          <article-title>¨rder. A synchronization concept for the DOM API</article-title>
          . In H. Ho¨ pfner, G. Saake, and E. Schallehn, editors,
          <source>Grundlagen von Datenbanken</source>
          , pages
          <fpage>80</fpage>
          -
          <lpage>84</lpage>
          . Fakulta¨t fu¨ r Informatik,
          <source>Universita¨t Magdeburg</source>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>H.</given-names>
            <surname>Hosoya</surname>
          </string-name>
          and
          <string-name>
            <given-names>B.</given-names>
            <surname>Pierce</surname>
          </string-name>
          .
          <article-title>Xduce: A statically typed XML processing language</article-title>
          ,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>A.</given-names>
            <surname>Laux</surname>
          </string-name>
          and
          <string-name>
            <given-names>L.</given-names>
            <surname>Martin. XUpdate - XML Update Language</surname>
          </string-name>
          ,
          <year>2000</year>
          . available online at http://xmldborg.sourceforge.net/xupdate/index.html.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>P.</given-names>
            <surname>Lehti</surname>
          </string-name>
          .
          <article-title>Design and implementation of a data manipulation processor for an XML query language</article-title>
          .
          <source>Master's thesis</source>
          , Technische Universitaet Darmstadt,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>P.</given-names>
            <surname>Loupal. Experimental DataBase (ExDB) Project</surname>
          </string-name>
          <article-title>Homepage</article-title>
          . http://swing.felk.cvut.cz/~loupalp.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>P.</given-names>
            <surname>Loupal</surname>
          </string-name>
          .
          <article-title>Updating typed XML documents using a functional data model</article-title>
          . In J. Pokorny´ ,
          <string-name>
            <surname>V.</surname>
          </string-name>
          <article-title>Sna´sˇel, and</article-title>
          K. Richta, editors,
          <source>DATESO</source>
          , volume
          <volume>235</volume>
          <source>of CEUR Workshop Proceedings. CEUR-WS.org</source>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>P.</given-names>
            <surname>Loupal</surname>
          </string-name>
          .
          <article-title>Using taDOM Locking Protocol in a Functional XML Update Language</article-title>
          .
          <source>In DATESO</source>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>J.</given-names>
            <surname>Pokorny</surname>
          </string-name>
          <article-title>´ . XML functionally</article-title>
          . In B. C. Desai,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Kioki</surname>
          </string-name>
          , and M. Toyama, editors,
          <source>Proceedings of IDEAS2000</source>
          , pages
          <fpage>266</fpage>
          -
          <lpage>274</lpage>
          . IEEE Comp. Society,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>J.</given-names>
            <surname>Pokorny</surname>
          </string-name>
          <article-title>´ . XML-λ: an extendible framework for manipulating XML data</article-title>
          .
          <source>In Proceedings of BIS 2002</source>
          , pages
          <fpage>160</fpage>
          -
          <lpage>168</lpage>
          , Poznan,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>G. M.</given-names>
            <surname>Sur</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Hammer</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Sime</surname>
          </string-name>
          <article-title>´on. An XQueryBased Language for Processing Updates in XML</article-title>
          .
          <source>In PLAN-X</source>
          <year>2004</year>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>I.</given-names>
            <surname>Tatarinov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z. G.</given-names>
            <surname>Ives</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. Y.</given-names>
            <surname>Halevy</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D. S.</given-names>
            <surname>Weld</surname>
          </string-name>
          .
          <article-title>Updating XML</article-title>
          .
          <source>In ACM SIGMOD</source>
          <year>2001</year>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>P.</given-names>
            <surname>Sˇ</surname>
          </string-name>
          <article-title>a´rek. Implementation of the XML lambda language</article-title>
          .
          <source>Master's thesis</source>
          , Dept. of Software Engineering, Charles University, Prague,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>