Book contents
- Frontmatter
- Contents
- Introduction
- Part 1 Modeling Web Data
- 1 Data Model
- 2 XPath and XQuery
- 3 Typing
- 4 XML Query Evaluation
- 5 Putting into Practice: Managing an XML Database with eXist
- 6 Putting into Practice: Tree Pattern Evaluation Using SAX
- Part 2 Web Data Semantics and Integration
- Part 3 Building Web Scale Applications
- Bibliography
- Index
6 - Putting into Practice: Tree Pattern Evaluation Using SAX
from Part 1 - Modeling Web Data
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Introduction
- Part 1 Modeling Web Data
- 1 Data Model
- 2 XPath and XQuery
- 3 Typing
- 4 XML Query Evaluation
- 5 Putting into Practice: Managing an XML Database with eXist
- 6 Putting into Practice: Tree Pattern Evaluation Using SAX
- Part 2 Web Data Semantics and Integration
- Part 3 Building Web Scale Applications
- Bibliography
- Index
Summary
In this chapter, we learn how to build an evaluation engine for tree-pattern queries, using the SAX (Simple API for XML) programming model. We thereby follow a dual goal: (i) improve our understanding of XML query languages and (ii) become familiar with SAX, a stream parser for XML, with an event-driven API. Recall that the main features of SAX were presented in Section 1.4.2.
TREE-PATTERN DIALECTS
We will consider tree-pattern languages of increasing complexity. We introduce them in this section.
C-TP This is the dialect of conjunctive tree-patterns. A C-TP is a tree, in which each node is labeled either with an XML element name, or with an XML attribute name. C-TP nodes corresponding to attributes are distinguished by prefixing them with @ (e.g., @color). Each node has zero or more children, connected by edges that are labeled either / (with the semantics of child) or // (with the semantics of descendant). Finally, the nodes that one wants to be returned are marked.
As an example, Figure 6.1 shows a simple XML document d where each node is annotated with its preorder number. (Recall the definition of this numbering from Section 4.2.) Figure 6.2 shows a C-TP pattern denoted t1 and the three tuples resulting from “matchings” of t1 into d.
- Type
- Chapter
- Information
- Web Data Management , pp. 131 - 140Publisher: Cambridge University PressPrint publication year: 2011