2/10/05Salman Azhar: Database Systems1 XML Query Languages Salman Azhar XPATH XQUERY These slides use some figures, definitions, and explanations from.

Slides:



Advertisements
Similar presentations
Advanced Operating Systems
Advertisements

Advanced Operating Systems
11 MANAGING DISKS AND FILE SYSTEMS Chapter 3. Chapter 3: Managing Disks and File Systems2 OVERVIEW Monitor and configure disks Monitor, configure, and.
XML Examples. Bank Information Basic structure: A-101 Downtown 500 … Johnson Alma Surrey … A-101 Johnson …
Trusted Platform Module
Session 8: Virtual Memory management
8. Virtual Memory 8.1 Principles of Virtual Memory
Automatic Trust Negotiation 1Dennis Kafura – CS5204 – Operating Systems.
University of Amsterdam, Distributed Systems1 Distributed Systems DOAS Marinus Maris.
State Feedback Controller Design
File Systems 1Dennis Kafura – CS5204 – Operating Systems.
XML: Extensible Markup Language
10/11/2014 5:29 AM4.5 - Matrix Inverse and Solving Systems1 Warm-Up #2 Find the determinants: Use Cramer’s Rule to determine the solution: 3. 6 –2.
Operating Systems1 10. File Systems 10.1 Basic Functions of File Management 10.2 Hierarchical Model of a File System 10.3 User’s View of Files –Logical.
Operating Systems ECE344 Midterm review Ding Yuan
Time Response and State Transition Matrix
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
1 DTD (Document Type Definition) Imposing Structure on XML Documents (W3Schools on DTDs)W3Schools on DTDs.
XML: Extensible Markup Language. Slide Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree)
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
2/6/05Salman Azhar: Database Systems1 XML Salman Azhar Semi-structured Data XML (Extensible Markup Language) Well-formed and Valid XML Document Type Definitions.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
From Semistructured Data to XML: Migrating The Lore Data Model and Query Language Roy Goldman, Jason McHugh, Jennifer Widom Stanford University
1 XPath Path Expressions Conditions. 2 Paths in XML Documents uXPath is a language for describing paths in XML documents. uReally think of the semistructured.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 357 Database Systems I Query Languages for XML.
1 COS 425: Database and Information Management Systems XML and information exchange.
Managing XML and Semistructured Data Lecture 6: XPath Prof. Dan Suciu Spring 2001.
4/17/2017.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
1 XML Query Languages XPATH XQUERY. 2 XPATH and XQUERY uXPATH is a language for describing paths in XML documents. wReally think of the semistructured.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 XQuery Values FLWR Expressions Other Expressions.
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
SD2520 Databases using XML and JQuery
XML Document Type Definitions XML Schema. Motivation for Semistructured data Serves as a model suitable for integration of databases Notations such as.
Lecture 7 of Advanced Databases XML Querying & Transformation Instructor: Mr.Ahmed Al Astal.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
Chapter 26 XML and Internet Databases Copyright © 2004 Pearson Education, Inc.
Advance Database S Week-7 Dr.Kwanchai Eurviriyanukul
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
Winter 2006Keller, Ullman, Cushing18–1 Plan 1.Information integration: important new application that motivates what follows. 2.Semistructured data: a.
Copyright © 2004 Pearson Education, Inc.. Chapter 26 XML and Internet Databases.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
Database Systems Part VII: XML Querying Software School of Hunan University
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 26-2 Introduction Although.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
Jeff Ullman: Introduction to XML 1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
More XML: semantics, DTDs, XPATH February 18, 2004.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
1 XML Data Management Extracting Data from XML: XPath Werner Nutt based on slides by Sara Cohen, Jerusalem.
1 XML Data Management XPath Principles Werner Nutt.
XML Query Languages XPATH XQUERY Zaki Malik November 11, 2008.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
Query Languages for XML
XML: Extensible Markup Language
Querying and Transforming XML Data
CS 480: Database Systems Lecture 28 March 22, 2013.
XML: Extensible Markup Language
XML Path Language Andy Clark 17 Apr 2002.
2/18/2019.
Lecture 11: XML and Semistructured Data
Query Languages for XML
Presentation transcript:

2/10/05Salman Azhar: Database Systems1 XML Query Languages Salman Azhar XPATH XQUERY These slides use some figures, definitions, and explanations from Elmasri- Navathes Fundamentals of Database Systems and Molina-Ullman-Widoms Database Systems

2/10/05Salman Azhar: Database Systems2 XPATH and XQUERY Two query language to search in XML documents XPATH Language for describing paths XQUERY Language for querying XML documents

2/10/05Salman Azhar: Database Systems3 XPATH A language for describing paths in XML documents More precisely XPATH describes semistructured data graph and its paths XML documents can be described as semi- structured data graphs each subobject as a node of a graph with its subobjects as its children

2/10/05Salman Azhar: Database Systems4 XQUERY XQUERY is a full query language for XML documents using path expressions from XPATH XQUERY use FLWR (pronounced flower) expression corresponds to SQLs select-from-where FLWR stands for for-let-where-return

2/10/05Salman Azhar: Database Systems5 Example DTD <!DOCTYPE Rests [ ]> RESTS have 0 or more REST & SODA Every REST has 1 or more PRICE and also an attribute name PRICE has data for price & the Soda with that price SODA name for ID and IDREFs for the rest that sell the soda.

2/10/05Salman Azhar: Database Systems6 Example Document … <SODA name = Dew, soldBy = JoesRest, SuesRest,…> …

2/10/05Salman Azhar: Database Systems7 XPATH Path Descriptors Let us study XPATH first Queries are really path descriptors Look like UNIX path description with tags instead of directories and files Tags are separated by / Simple path descriptors are sequences of tags separated by slashes (/)

2/10/05Salman Azhar: Database Systems8 Example: /RESTS/REST/PRICE … <SODA name = Dew, soldBy = JoesRest, SuesRest,…> … /RESTS/REST/PRICE describes The set with these two PRICE Objects as well as the PRICE objects for any other restaurants.

2/10/05Salman Azhar: Database Systems9 XPATH Path Descriptors If the descriptor begins with /, then the path starts at the root and has those tags, in order If the descriptor begins with //, then the path can start anywhere

2/10/05Salman Azhar: Database Systems10 Example: //PRICE … <SODA name = Dew, soldBy = JoesRest, SuesRest,…> … //PRICE describes the same PRICE objects, but only because the DTD forces every PRICE to appear within a RESTS and a REST.

2/10/05Salman Azhar: Database Systems11 Wild-Card * A star (*) in place of a tag represents any one tag acts as a wildcard Example: /*/*/PRICE represents all price objects at the third level of nesting

2/10/05Salman Azhar: Database Systems12 Example: /RESTS/* … <SODA name = Dew, soldBy = JoesRest, SuesRest,…> … /RESTS/* captures all REST and SODA objects, such as these.

2/10/05Salman Azhar: Database Systems13 Attributes We may refer to attributes in addition to tags In XPATH, we refer to attributes by pre- to their name Attributes of a tag may appear in paths as if they were nested within that tag

2/10/05Salman Azhar: Database Systems14 Example: … <SODA name = Dew, soldBy = JoesRest, SuesRest,…> … selects all name attributes of immediate subobjects of the RESTS object.

2/10/05Salman Azhar: Database Systems15 Selection Conditions A condition inside […] may follow a tag If so, the only paths included in the result of a path expression are ones that have that tag and also satisfy the condition

2/10/05Salman Azhar: Database Systems16 Example: Selection Condition /RESTS/REST/PRICE[PRICE < 1.60] … The condition that the PRICE be < $1.60 makes this price but not the price of Slice satisfy the path descriptor.

2/10/05Salman Azhar: Database Systems17 Example: Attribute in Selection = Slice] … Now, this PRICE object is selected, along with any other prices for Slice.

2/10/05Salman Azhar: Database Systems18 Optional: Axes In general, path expressions allow us to start at the root and execute a sequence of steps to find a set of nodes at each step, we may follow any one of several axes The default axis is child:: go to any child of the current set of nodes

2/10/05Salman Azhar: Database Systems19 Optional: Example of Axes /RESTS/SODA is really shorthand for is really shorthand for the attribute:: axis. Thus, = Dew ] is shorthand for /RESTS/SODA[attribute::name = Dew]

2/10/05Salman Azhar: Database Systems20 Optional: More Axes Some other useful axes are: 1. parent:: = parent(s) of the current node(s) 2. descendant-or-self:: = the current node(s) and all descendants w Note: // is really a shorthand for this axis. 3. ancestor::, ancestor-or-self, etc.

2/10/05Salman Azhar: Database Systems21 XQUERY XQUERY allows us to query XML documents using path expressions from XPATH to describe important sets XQUERY use FLWR (pronounced flower) expressions stands for for-let-where-return corresponds to SQLs select-from-where

2/10/05Salman Azhar: Database Systems22 XQUERY SQL Mapping where WHERE return SELECT for/let FROM

2/10/05Salman Azhar: Database Systems23 FLWR (FLoWeR) Expressions FLWR expressions are made up of 1. One or more FOR and/or LET clauses. 2. Then an optional WHERE clause. 3. A RETURN clause.

2/10/05Salman Azhar: Database Systems24 FOR Clauses FOR IN,… Variables begin with $. A FOR variable takes on each object in the set denoted by the path expression (in turn) Whatever follows this FOR is executed once for each value of the variable creates a loop

2/10/05Salman Azhar: Database Systems25 Example: FOR FOR $soda IN RETURN $soda $soda ranges over the name attributes of all sodas in our example document Result is a list of tagged names, like Dew Slice …

2/10/05Salman Azhar: Database Systems26 LET Clauses LET :=,… Value of the variable becomes the set of objects defined by the path expression Note: LET does not cause iteration FOR does cause iteration

2/10/05Salman Azhar: Database Systems27 Example: LET LET $sodas := RETURN $sodas Returns one object with all the names of the sodas, like: Dew, Slice,…

2/10/05Salman Azhar: Database Systems28 Following IDREFs XQUERY (but not XPATH) allows us to use paths that follow attributes that are IDREFs If x denotes a set of IDREFs, then x =>y denotes all the objects with tag y whose IDs are one of these IDREFs

2/10/05Salman Azhar: Database Systems29 Example Find all the soda objects where the soda is sold by Joes Rest for less than 1.60 Strategy: 1. $soda will for-loop over all soda objects 2. For each $soda, a. let $joe be either the Joes-Rest object, if Joe sells the soda, b. or the empty set of rest objects. 3. Test whether $joe sells the soda for < 1.60

2/10/05Salman Azhar: Database Systems30 Example: The Query FOR $soda IN /RESTS/SODA LET $joe := LET $joePrice := WHERE $joePrice < 1.60 RETURN $soda Attribute soldBy is of type IDREFS. Follow each ref to a REST and check if its name is Joes Rest. Find that PRICE subobject of the Joes Rest object that represents whatever soda is currently $soda. Only pass the values of $soda, $joe, $joePrice to the RETURN clause if the string inside the PRICE object $joePrice is < 1. 60

2/10/05Salman Azhar: Database Systems31 Summary Two query language to search in XML documents XPATH Queries are really path descriptors XQUERY SQL like language for querying XML documents