XQuery – The W3C XML Query Language Jonathan Robie, Software AG Don Chamberlin, IBM Research Daniela Florescu, INRIA.

Slides:



Advertisements
Similar presentations
XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
Advertisements

Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.
Web Data Management XQuery 1. In this lecture Summary of XQuery FLWOR expressions – For, Let, Where, Order by, Return FOR and LET expressions Collections.
XML May 3 rd, XQuery Based on Quilt (which is based on XML-QL) Check out the W3C web site for the latest. XML Query data model –Ordered !
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
XQuery John Annechino Steven Pow. Agenda What is XQuery? Uses of XQuery XQuery vs. XSLT Syntax –Built-In Functions –FLWOR –if-then-else –User-Defined.
XQUERY. What is XQuery? XQuery is the language for querying XML data The best way to explain XQuery is to say that XQuery is to XML what SQL is to database.
1 XQuery Web and Database Management System. 2 XQuery XQuery is to XML what SQL is to database tables XQuery is designed to query XML data What is XQuery?
Dickson K.W. Chiu PhD, SMIEEE Thanks to Prof. Francis Lau (HKU)
Friday, September 4 th, 2009 The Systems Group at ETH Zurich XML and Databases Exercise Session 6 courtesy of Ghislain Fourny/ETH © Department of Computer.
Querying XML (cont.). Comments on XPath? What’s good about it? What can’t it do that you want it to do? How does it compare, say, to SQL?
IS432: Semi-Structured Data Dr. Azeddine Chikh. 7. XQuery.
QSX (LN 3)1 Query Languages for XML XPath XQuery XSLT (not being covered today!) (Slides courtesy Wenfei Fan, Univ Edinburgh and Bell Labs)
Object-Orientation in Query Languages By: Toan Nguyen Class: CS 157A.
A Graphical Environment to Query XML Data with XQuery
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 357 Database Systems I Query Languages for XML.
XQL (XML Query Language) Jonathan Robie (Software AG) Eduard Derksen (CSCIO) Peter Fankhauser (GMD-IPSI) Ed Howland (DEGA) Gerald Huck (GMD-IPSI) Ingo.
XQuery language Presented by: Tayeb sbihi supervised by: Dr. H. Haddouti.
1 COS 425: Database and Information Management Systems XML and information exchange.
Query Languages - XQuery Slides partially from Dan Suciu.
XML May 1 st, XML for Representing Data John 3634 Sue 6343 Dick 6363 John 3634 Sue 6343 Dick 6363 row name phone “John”3634“Sue”“Dick” persons.
SDPL 2001Notes 8.2: XQuery1 8.2 W3C XML Query Language –Thanks for Helena Ahonen-Myka (University of Helsinki) for borrowing her slide originals for this.
XML QUERY LANGUAGE Prepared by Prof. Zaniolo, Hung-chih Yang, Ling-Jyh Chen Modified by Fernando Farfán.
XML, XML Schema, XPath and XQuery Query Languages CS561 Slides collated from several sources, including D. Suciu at Univ. of Washington.
Xpath to XQuery February 23rd, Other Stuff HW 3 is out. Instructions for Phase 3 are out. Today: finish Xpath, start and finish Xquery. From Wednesday:
Querying XML February 12 th, Querying XML Data XPath = simple navigation through the tree XQuery = the SQL of XML XSLT = recursive traversal –will.
Processing of structured documents Spring 2003, Part 8 Helena Ahonen-Myka.
XML Query Language Changki Kim July MSE. 2 2 Contents  Introduction  XQuery Data Model  XQuery Expression Types  Implementations of XQuery.
XQuery Your gateway to manipulating XML in SQL Server 2005.
Advisor: Prof. Zaniolo Hung-chih Yang Ling-Jyh Chen XML Query Language.
Xquery. Summary of XQuery FLWR expressions FOR and LET expressions Collections and sorting Resource W3C recommendation:
Lecture 21 XML querying. 2 XSL (eXtensible Stylesheet Language) In HTML, default styling is built into browsers as tag set for HTML is predefined and.
Introduction to XQuery Resources: Official URL: Short intros:
XML-QL A Query Language for XML Charuta Nakhe
1 XML INTEROPERABILITY Manjusha Ravindranath. 2 CONTENTS Introduction Interoperability XSSQL syntax Usecases document Group By -Without aggregation -With.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
Query Processing with XML CSE 350 – Advanced Database Topics Jeffrey R. Ellis.
Comparing XSLT and XQuery Michael Kay XTech 2005.
IBM Research © 2005 IBM Corporation XJ: Robust XML Processing in Java™ Mukund Raghavachari, Rajesh Bordawekar, Michael Burke, and Igor Peshansky IBM T.
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.
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.
A Quilt, not a Camel Don Chamberlin Jonathan Robie Daniela Florescu May 19, 2000.
Company LOGO OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro.
Introduction to XQuery Bun Yue Professor, CS/CIS UHCL.
XQL, OQL and SQL Xia Tang Sixin Qian Shijun Shen Feb 18, 2000.
Nikos dimitrakas – IS4/2i1242/2i4042 spring XML Query Languages Database Systems (4th edition) Chapter 30.5, , Articles & Excerpts.
Using Special Operators (LIKE and IN)
Database Systems Part VII: XML Querying Software School of Hunan University
SDPL 2002Notes 9: XQuery1 9 Querying XML Data and Documents n XQuery, W3C XML Query Language –"work in progress", Working Draft, 30 April 2002 –joint work.
XQuery Leah Andrews. Overview  Queries data stored in XML trees  Declarative  High-level  Functional (no side effects)  Strongly typed  Nodes 
XML Databases by Sebastian Graf Hier beginnt mein toller Vortrag.
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
XML query. introduction An XML document can represent almost anything, and users of an XML query language expect it to perform useful queries on whatever.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
XML May 6th, Instructor AnHai Doan Brief bio –high school in Vietnam & undergrad in Hungary –M.S. at Wisconsin –Ph.D. at Washington under Alon &
IS432 Semi-Structured Data Lecture 6: XQuery Dr. Gamal Al-Shorbagy.
19 th International Unicode Conference San Jose, CA September W3C XML Query Paul Cotton, Microsoft 19 th Unicode Conference Sept 12, 2001.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
Lecture 17: XPath and XQuery Wednesday, Nov. 7, 2001.
1 CSE544: Lecture 7 XQuery, Relational Algebra Monday, 4/22/02.
SDPL 2005Notes 7: XQuery1 7 Querying XML n How to access different sources (DBs, docs) as XML? n XQuery, W3C XML Query Language –"work in progress", (last.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
XML Data: Part 2 เอกสารภาค บรรยาย ดร. มารุต บูรณรัช : หัวข้อพิเศษด้านเทคโนโลยีสารสนเทศขั้นสูง - เทคโนโลยีเว็บเชิงความหมาย.
Querying XML and Semistructured Data
Querying XML XQuery.
Querying XML XQuery.
XQuery Leonidas Fegaras.
Presentation transcript:

XQuery – The W3C XML Query Language Jonathan Robie, Software AG Don Chamberlin, IBM Research Daniela Florescu, INRIA

2 XQuery Design Goals Expressive power Major functionality of XML-QL, XQL, SQL, OQL - query the many kinds of data XML contains! Use-case driven approach Can be implemented in many environments Traditional databases, XML repositories, XML programming libraries, etc. Queries may combine data from many sources Minimalism and good design Small, easy to understand, clean semantics “A quilt, not a camel”

3 XML: Many Environments DOM SAX DBMS XML Java COBOL DOM SAX DBMS XML Java COBOL XQuery W3C XML Query Data Model W3C XML Query Data Model

The XQuery Language

5 XQuery Expressions XQuery is a functional language A query is an expression Expressions can be combined flexibly Structure of a query Namespace declarations (optional) Function definitions (optional) The query expression – often composed of many expressions

6 XQuery Expressions Path expressions: /a//b[c = 5] FLWR expressions: FOR... LET... WHERE... RETURN Element constructors:... Variables and constants: $x, 5 Operators and function calls: x + y, -z, foo(x, y) Conditional expressions: IF... THEN... ELSE Quantifiers: EVERY var IN expr SATISFIES expr Sorted expressions: expr SORTBY (expr ASCENDING,... ) Preliminary proposal for INSERT, REPLACE, DELETE

7 A Sample Document TCP/IP Illustrated Stevens W. Addison-Wesley 65.95

8 Element Constructors # Element constructors look like the XML they construct TCP/IP Illustrated Stevens W. Addison-Wesley 65.95

9 Path Expressions TCP/IP Illustrated Stevens W. Addison-Wesley # XQuery uses the abbreviated syntax # of XPath for path expressions document(“bib.xml”) /bib/book/author //author[last=“Stevens” and first=“W.”] document(“bib.xml”)//author

10 Path Expressions - Extensions # Range expressions /bib/book/author[1 TO 2] # BEFORE and AFTER //book[ author[last=“Stevens”] BEFORE author[last=“Abiteboul”] ] # Namespaces NAMESPACE rev = " //rev:rating # Dereference

11 FLWR Expressions FOR - LET - WHERE - RETURN Similar to SQL’s SELECT - FROM - WHERE FOR $book IN document("bib.xml")//book WHERE $book/publisher = "Addison-Wesley" RETURN { $book/title, $book/author }

12 FOR vs. LET FOR iterates on a sequence, binds a variable to each node LET binds a variable to a sequence as a whole FOR $book IN document("bib.xml")//book LET $a := $book/author WHERE contains($book/publisher, "Addison-Wesley”) RETURN { $book/title, Number of authors: { count($a) } }

13 Inner Joins FOR $book IN document(" $quote IN document(" WHERE $book/isbn = $quote/isbn RETURN { $book/title } { $quote/price } SORTBY (title)

14 Outer Joins FOR $book IN document("bib.xml")//book RETURN { $book/title } { FOR $review IN document("reviews.xml")//review WHERE $book/isbn = $review/isbn RETURN $review/rating } SORTBY (title)

15 Combining Expressions { FOR $book IN document("bib.xml")//book RETURN { $book/author, $book/title } SORTBY (author, title) }

16 Combining Expressions Expression

17 Combining Expressions { FOR $book IN Expression RETURN Expression }

18 Combining Expressions { FOR $book IN Expression RETURN { Expression, Expression } SORTBY (Expression, Expression) }

19 Combining Expressions { FOR $book IN document("bib.xml")//book RETURN { $book/author, $book/title } SORTBY (author, title) }

20 Functions Built-in functions max(), min(), sum(), count(), avg() distinct(), empty(), contains() the normative set has not yet been fixed User-defined functions Defined in XQuery syntax May be recursive May be typed Extensibility mechanisms planned

21 Functions FUNCTION depth(ELEMENT $e) RETURNS integer { -- An empty element has depth 1 -- Otherwise, add 1 to max depth of children IF empty($e/*) THEN 1 ELSE max(depth($e/*)) + 1 } depth(document("partlist.xml"))

22 Data Types W3C XML Schema simple types string "Hello" boolean true, false integer 47, -369 float -2.57, 3.805E-2 Type constructor functions date(" ") Operators and functions to be defined...

Data Transformations

24 Bibliography Harold and the Purple Crayon Johnson Crockett Harper and Row

25 Books by Author Harold and the Purple Crayon Johnson Crockett Harper and Row Johnson Crockett Harold and the Purple Crayon Harold’s Fairy Tale Harold and the Circus Harold’s ABC’s...

26 Inverting the Hierarchy Harold and the Purple Crayon Johnson Crockett Harper and Row FOR $a IN distinct(document("powerpoint/bib.xml")//book/author) LET $b := document("powerpoint/bib.xml")//book[author = $a] RETURN { $a } { $b/title SORTBY (.) } SORTBY(author/last, author/first)

Updates (preliminary)

28 INSERT, DELETE, REPLACE INSERT FOR $e IN /emp INSERT count($e/skill) BEFORE $e/skill[1] REPLACE FOR $e IN /emp WHERE $e/empno = "1234” REPLACE $e/job WITH "Broom Tester"

29 INSERT, DELETE, REPLACE DELETE FOR $e IN /emp/[job = "Programmer"], $s IN $e/skill WHERE $s/rating < 4 OR $s/cert_date < date(" ") DELETE $s

30 Limitations on Update No distributed update - single data source No updates on views

Summary

32 Why XQuery? The W3C XML Query Language Many DOM+XPath+XSLT applications can now be implemented in just one language Expressive, concise, easy to learn Implementable, optimizable Data integration for multiple sources Several current implementations Preliminary update proposal

33 For More Information W3C XQuery W3C XML Query Use Cases W3C XML Query Requirements W3C XML Query Data Model W3C XML Query Algebra

34