clea
Uploaded by
17 SLIDES
321 VIEWS
170LIKES

Efficient XPath Query Evaluation: A Top-Down Approach

DESCRIPTION

This paper presents an in-depth study of XPath query evaluation using a top-down approach, highlighting its importance in selecting nodes within XML documents and its applications in XSLT and XQuery. It contrasts polynomial versus exponential time complexities and provides algorithmic implementations for various XPath axes and node types. Key concepts include the structure of XPath expressions, node testing expressions, and the evaluation relative to context. The authors also discuss complexities and present benchmark results comparing implementations, providing insights into efficient XPath processing.

1 / 17

Download Presentation

Efficient XPath Query Evaluation: A Top-Down Approach

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XPath Query Evaluation- A Top Down Approach Mohammed Pithapurwala (mp66@cse.buffalo.edu) Pejus Das (pejusdas@cse.buffalo.edu)

  2. Introduction • XPath Query Evaluation • Uses: • Select nodes in XML document • XSLT, XQuery • Polynomial V/s Exponential • Top Down Algorithm

  3. XPath • What is XPath? • child::section[position()<6] / descendant::cite / attribute::href • selects all href attributes in cite elements in the first 5 sections of an article document • Structure of XPath expression • Axes • Node types • Node test • Returns • Number, node set, string, boolean

  4. Implementation • XPath Axes • Child • Parent • Descendant • Axes Functions • FirstChild • nextSibling • Child := firstchild.nextsibling* • Parent := (nextsibling-1)*.firstchild-1 • Descendant := firstchild.(firstchild  nextsibling)*

  5. Code Snippet public static Element firstChild(Element currNode) { Element fChild; fChild = null; List childNode = currNode.getChildren(); Iterator iterator = childNode.iterator(); if(iterator.hasNext()) { fChild = (Element) iterator.next(); } return(fChild); }

  6. Node Test & Expressions • Node Test Expression • T(node()) = all nodes in the document • T(attribute(href)) – all nodes labelled href • attribute(S) := child(S) T(attribute()) • Node Numbering • < doc, X • The node order relative to the axes X in document order • idxx(x,S) • Context • c = x, k, n • x: node • k: position of the node • n: context size • Evaluation of XPath relative to context

  7. XPath Evaluation • X::t[e] • X  {child, parent, descendant, ….} • t : node test expression • e: expression • Expressions • e  {node set, number, string, boolean} • ArithOp  {+, -, *, div, mod} • EqOP  {, }

  8. XPath Semantics x, k, n := P(x) position() (x, k, n) := k last() (x, k, n) := n For all other kinds of expressions, e = Op(e1, …, em) Op(e1, …, em)(c) := Op(e1(c),….,em(c)) maps a context to a value type.

  9. Intuitive Algorithm P [::te1 … em (x) := begin S := {y | x  y, y  T(t)}; for 1  i  m (in ascending order) do S := {y  S | ei (y, idx(y,S), |S| = true}; return S; end; P1|2(x) := P1(x) P2(x) P/ (x) := P(root) P1/2(x) := Uy  P[1](x)P2(y)

  10. Runtime • Ex: • Doc: <a><b/><b/></a> • Query: //a/b/parent::a/b/parent::a/b • Construct more queries: /parent::a/b • procedure process-location-step(n0, Q) • /* n0 is the context node; query Q is a list of location steps */ • begin • node set S := apply Q.head to node n0; • if (Q.tail is not empty) then • for each node n 2 S do process-location-step(n, Q.tail); • End • Complexity: Time(|Q|) = |D||Q|

  11. Algorithm • S::t[e1]…[em](X1, … ,Xk) := • begin • S := {x,y| x Xi , x  y, and y T(t)}; • for each 1≤ i ≤ m (in ascending order) do • begin • Fix some order S = x1,y1 , …, xl,yl for S; • r1,…rl := ei(t1,…,tl) where tj =  yj , idx (yj,, Sj ), |Sj|  and Sj := {z |  xj, z  S}; • S := {xi,yi |ri is true}; • end; • for each 1 ≤ i ≤ k do • Ri := {y |  x, y  S, x  Xi}; • return R1, … ,Rk ; • end;

  12. Algorithm (contd….) S/(X1, …., Xk) := S({root}, …., k times) S1/2(X1, …., Xk) := S2(S1(X1, …., Xk)) S1|2(X1, …., Xk) := S1(X1, …., Xk) U (S2(X1, …., Xk))

  13. Semantics Function (x1, k1, n1, …, xl, kl, nl) := S({x1}, …., {xl}) position()(x1, k1, n1, …, xl, kl, nl) := k1, …., kl last()(x1, k1, n1, …, xl, kl, nl) := n1, …., nl And Op(e1, …. em(c1, …., cl) := Op  (e1(c1, …., cl), …., em(c1, …., cl)) For remaining kind of expressions

  14. Benchmark Results in seconds for IE6 vs. the implementation

  15. References • G. Gottlob, Ch. Koch, R. Pichler: XPath Processing in a Nutshell. SIGMOD Record, March'03. • G. Gottlob, Ch. Koch, R. Pichler: Efficient Algorithms for Processing XPath Queries. ACM TODS, to appear.

  16. ?

  17. Thank You!!

More Related