cis562f10_note9_XQuery1 (3)

cis562f10_note9_XQuery1 (3) - Chapter 5 XML Query Languages...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 5 XML Query Languages Reading: pp. 91 – 166 and 75 – 90 in Coursepack; Lecture Notes 1. Overview — Problem: how to query XML data? General programming approach: descriptive – describe how to do it: much burden on user side. Query language approach: declarative – say what you want: less work, more optimization opportunities. XPath -- locate nodes in an XML doc: serves as a base for others XQuery -- query XML documents: a comprehensive language XSLT -- transform an XML document into another XML/HTML: mainly for rendition SQL/XML -- extended SQL to handle XML data in tables (e.g., query/export) In this course, we only discuss the first three query languages
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 2. XPath — Stands for X ML P ath L anguage — Use path expressions to locate nodes in XML data • Sample data for examples
Background image of page 2
3 Notes: * The data model used for XPath is the XQuery data model we discussed previously. * An XML doc is viewed as an ordered, labeled tree, or equivalently a sequence of items in the document order. • Path expression — Consist of a series of one or more steps, separated by “/” or “//”, which are executed in order from left to right. E.g., doc(“books.xml”)/bib/book doc(“books.xml”)//book
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 doc() – an input function to return the document node of the document node of the document. The 1st step can also be a variable or other functions to give the input sequence of nodes. / -- child // -- self-or-descendant — For each /: - We evaluate the left step (expression) and return the resulting nodes in document order. - We then evaluate the right step (expression) once for each left resulting node and merge the results into a sequence of nodes in document order. — Context node: the left node for which the right step is being evaluated. • Step expression — Each step consists of three parts: the axis (optional), the node test, and zero or more predicates.
Background image of page 4
5 •Ax is — the direction of travel: most common ones are given in the following table: descendant-or-self // x/descendant-or-self::y x//y
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 * Name tests — Select element node or attribute node (of the context node) based on their names • Node tests the context node) based on their names. — Support both wildcards and namespaces.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

cis562f10_note9_XQuery1 (3) - Chapter 5 XML Query Languages...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online