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
2 - XPath and XQuery
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
INTRODUCTION
This chapter introduces XPath and XQuery, two related languages that respectively serve to navigate and query XML documents. XPath is actually a subset of XQuery. Both languages, specified by theW3C, are tightly associated and share in particular the same conceptual modeling of XML documents. Note that the XPath fragment of XQuery has a well-identified purpose (expressing “paths” in an XML tree) and as such can be used independently in other XML processing contexts, such as inside the XSLT transformation language. XQuery uses XPath as a core language for path expressions and navigation.
XQuery is a declarative language and intends to play for XML data the role of SQL in the relational realm. At a syntactical level, it is somewhat inspired from SQL. More importantly, it is expected to benefit from a mixture of physical storage, indexing, and optimization techniques in order to retrieve its result by accessing only a small fraction of its input. XQuery constitutes therefore an appropriate choice when large XML documents or large collections of documents must be manipulated.
In this chapter, we use as running example a movies XML database. Each XML document represents one movie and is similar in structure to the sample document shown in Figure 2.1.
We begin the chapter with a bird's-eye view of XQuery principles, introducing the XML data model that supports the interpretation of path expressions and queries, and showing the main features of the two languages. We then consider in more detail XPath and XQuery in a rather informal way.
- Type
- Chapter
- Information
- Web Data Management , pp. 32 - 71Publisher: Cambridge University PressPrint publication year: 2011