354.XQuery - Database Systems I Query Languages for XML...

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

View Full Document Right Arrow Icon
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 1 Database Systems I Query Languages for XML
Background image of page 1

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

View Full DocumentRight Arrow Icon
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 2 Query Languages for XML XPath is a simple query language based on describing similar paths in XML documents. XQuery extends XPath in a style similar to SQL, introducing iterations, subqueries, etc. XPath and XQuery expressions are applied to an XML document and return a sequence of qualifying items . Items can be primitive values or nodes (elements, attributes, documents). The items returned do not need to be of
Background image of page 2
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 3 XPath A path expression returns the sequence of all qualifying items that are reachable from the input item following the specified path. A path expression is a sequence consisting of tags or attributes and special characters such as slashes (“/”). Absolute path expressions are applied to some XML document and returns all elements that are reachable from the document’s root element following the specified path.
Background image of page 3

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

View Full DocumentRight Arrow Icon
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 4 XPath <?XML version=“1.0” standalone =“yes” ?> <bibliography> <book bookID = “b100“> <title> Foundations… </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> </bibliography> Applied to the above document, the XPath expression /bibliography/book/author returns the sequence <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> . . .
Background image of page 4
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 5 Attributes If we do not want to return the qualifying elements, but the value one of their attributes, we end the path expression with @attribute . Applied to the above document, the XPath expression /bibliography/book/@bookID returns the sequence “b100“ . . .
Background image of page 5

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

View Full DocumentRight Arrow Icon
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 6 Axes XPath provides a variety of axes , i.e. modes of navigation through semistructured data. At each step of a path expression, we can prefix a tag or attribute name by an axis name and a colon. For example, the path expression /child:: bibliography/ child:: book/ attribute:: boo kID is equivalent to /bibliography/book/@bookID.
Background image of page 6
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 7 Axes Axes include parent, ancestor, descendant, next-sibling, previous-sibling, self, and descendant-or-self. XPath has the following shorthands for axes: / child, // descendant-or-self, @ attribute, . self, .. parent.
Background image of page 7

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

View Full DocumentRight Arrow Icon
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 8 Axes <bibliography> <book bookID = “b100“> <title> Foundations… </title> <author affiliation = “IBM“> Abiteboul </author> <author> Hull </author> . . . </book> <article articleID = “a245“> <header> <author authorID = “a739“> Codd </author> <title> A relational database model </title> </header> <body> . . . </body> </article>
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/07/2009 for the course CS 12601 taught by Professor Kewang during the Spring '09 term at Simon Fraser.

Page1 / 34

354.XQuery - Database Systems I Query Languages for XML...

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

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