Xpath Query Containment‡

Xpath Query Containment‡

XPath Query Containmentz Thomas Schwentickx 1 Introduction Query Containment Problem are given and in Sec- tion 4 there is an overview of complexity results for Consider an XML publish-subscribe scenario with the problem. Finally, in Section 6 a couple of related hundreds of subscribers and tens of thousands of questions are discussed. Because of space limitations, XML documents to be delivered per day. Subscribers the examples in this survey are neither practical nor specify the documents in which they are interested in entertaining but as small as possible, using only tags by means of XPath [8] expressions. If an expression like <a>, <b>, etc. matches a (part of a) document it is delivered to the There are more reasons to study the XPath subscriber. Naturally, it is desired that the decision containment problem than the scenario mentioned to which subscriber a document must be sent should above. As XPath occurs as a sublanguage in other be taken quickly. Although the test whether a single XML languages (XQuery, XSLT, XLink, XPointer, XPath expression matches can be done in polynomial XML Schema,...) the problem of XPath query con- time, it is not e±cient to test every such expression tainment and the closely related questions of equiv- for every document. Fortunately, there is a partial alence and minimization are fundamental for query order on expressions, i.e., for some expressions p; q it optimization. might hold that whenever a document matches p it Further, as XPath is used to de¯ne keys in XML also matches q (denoted p ⊆0 q). If we already know Schema and other constraints can be speci¯ed by us- that a document matches p, we do not need to test q ing fragments of XPath, understanding the key and anymore, as it matches automatically. Correspond- constraint implication problem requires an under- ingly, if we know that q does not match then p will not standing of the XPath query containment problem match either. Hence, the inclusion structure of the [4]. XPath expressions should be computed in advance to Compared to the classical containment problem for decrease online computation time. This leads to the relational conjunctive queries, the problem is on the algorithmic problem of XPath Query Containment, one hand easier, as the structures are trees rather i.e., checking whether p ⊆0 q (for a di®erent, index- than arbitrary relational structures, but on the other based approach see, e.g., [6]). hand much harder, as the queries might involve recur- The main idea of this article is to describe some sion (e.g., by navigation along the descendant-axis). of the main algorithmic techniques that have been proposed for XPath Query Containment. These tech- niques are described in Section 5. Before that, in Sec- 2 XPath tions 2 and 3 the basic de¯nitions on XPath and the 2.1 Data model zDatabase Principles Column. Column editor: Leonid Libkin, Department of Computer Science, University of We model XML documents as rooted trees with la- Toronto, Toronto, Ontario M5S 3H5, Canada. E-mail: bels from an in¯nite (unranked) alphabet §. The [email protected]. symbols from § correspond to XML tags. Every node xPhilipps-UniversitÄat Marburg, FB Mathematik und In- formatik, 35032 Marburg, Germany, [email protected] corresponds to an element The root of the tree cor- marburg.de responds to the root element of the document and is denoted by root. Subelements are modelled by chil- s = x :: e p1 ¢ ¢ ¢ pk, the relation Rs(t) is de¯ned as the dren. We refer to such trees as XML trees. Figure set of pairs (u; v) of nodes, for which 1 displays a simple example document and its corre- ² (u; v) 2 A (t), sponding XML tree t0. x ² v matches e, i.e., e = ¤ or the label of v is e, and <a> <c></c> root <c> <b> </b> ² each set Rpi (t) contains at least one pair (v; w). </c> a a </a> For an expression p = s=q, where s is a step ex- c c b b <a> <b> </b> pression and q is an expression, the relation Rp(t) is f(u; v) j u; v; w 2 t; (u; w) 2 R (t); (w; v) 2 R (t)g. <b> <d> </d> b d c s q <c> <c> </c> Finally, Rpjq = Rp(t) [ Rq(t) and R=p is the set of all </c> c pairs (root; v) from Rp(t). </b> Hence, the expression p0 above de¯nes the set of all </a> pairs (u; v), where v is an element labelled c, which is a descendant of an element with arbitrary label, Figure 1: XML document and corresponding tree. which in turn is a child of a child of u with label a. Furthermore, this child has to possess a descen- dant with label d. Evaluated on the tree t0 we get the relation R = f(v1; v2); (v1; v3)g, where v1 is the 2.2 Syntax of XPath p0 right child of the root node, v3 is the rightmost leaf, In this article we only consider a fragment labelled c, and v2 is its parent. of XPath. For our purposes, a step ex- pression s is of the form axis `::' expr pred¤, 2.4 Abbreviated syntax where axis is one of the XPath axes self, child, descendant, descendant-or-self, parent, For the most frequently used kinds of steps along the ancestor, ancestor-or-self, following-sibling, forward axes there exists an abbreviated syntax. We preceding-sibling. Further, expr is a node test, write i.e., either a tag name or ¤. Finally pred¤ is a possi- ² p=e=q instead of p=child :: e=q, bly empty sequence of items of the form [p], where p is an expression as de¯ned below. ² p==e=q instead of p=descendant :: e=q, The syntax for expressions p is given by p ::= s j s`/'p j p`j'p j `/'p, where s is a step expression. An ² :=p instead of self :: ¤=p. expression of the form =p is called absolute. Other Hence, expression p0 can also be written as expressions are called relative. a[.//d]/¤//c. An example expression p0 is child::a[descendant::d]/child::¤/descendant::c. 2.5 Pattern trees 2.3 Semantics of XPath Expressions p which only use the child and descendant axes can be conveniently represented by For each axis x and each XML tree t, we denote by their pattern tree T (p). Each step of an expression Ax(t) the set of all pairs (u; v) of nodes from t such corresponds to a node, which is a child of the node that u and v are in x-relation. E.g., Achild contains of the previous step. Steps along the child axis are all pairs (u; v), for which v is the child of u. indicated by single lines, steps along the descendant Each expression p de¯nes, on each XML tree t, a axis by double lines. We refer to edges of the ¯rst binary relation Rp(t) as follows. For a step expression kind as child edges and to the others as descendant edges. A predicate expression of a step s gives rise An alternative notion of containment only consid- to a subtree of the node corresponding to s. The ers whether nodes match relative to the root of the node which corresponds to the last step of an expres- tree. Here, we interpret an expression p as abso- root sion (the selection node) is underlined to distinguish lute expression, de¯ning the set Rp (t) of nodes it from the leaves that are obtained from predicates. v, for which (root; v) 2 Rp(t). We write p ⊆1 q if root root Hence, the tree depicted in Figure 2 is the pattern Rp (t) ⊆ Rq (t), for every XML tree t. tree T (p0). Finally, we de¯ne Boolean containment which only asks whether p and q match at all, relative to the a root root. We write t j= p, if Rp (t) 6= ;. If t j= p d ¤ implies t j= q, for every XML tree t, then we write p ⊆0 q. c It turns out that all three containment notions are strongly related. If only the child and descendant Figure 2: Pattern tree for p0 axes are allowed ⊆2 and ⊆1 are actually equivalent. If predicates are allowed then it is even su±cient to It should be stressed that the order in which the consider Boolean queries. Figure 3 shows how the children of a node are depicted does not carry any tree pattern T (p0) can be modi¯ed into a new tree meaning. In particular, this order does not need to 0 pattern T (p0) by adding a child to its selection node. be matched in the document. 0 0 It holds that p ⊆1 q if and only p ⊆0 q [19]. In the remainder of this article, we will only consider 2.6 XPath fragments Boolean containment ⊆0. Therefore, in pattern trees we no longer distinguish a selection node. Work on XPath query containment has mainly fo- cussed on the two most important axes, child and a descendant. It even considered fragments, where d ¤ disjunction, predicates [q] and/or the wildcard ¤ are not allowed. We refer to such fragments by writing c XP(L), where L is a list of the allowed components in abbreviated notation. E.g., the fragment, where x 1 only child, predicates and wildcard are allowed is Figure 3: Pattern tree for p0 denoted by XP(=; [ ]; ¤).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us