Advisor: Prof. Zaniolo Hung-chih Yang Ling-Jyh Chen XML Query Language.

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

XQuery How to handle databases with the XML standard? Peter van Keeken Industrial trainee, Evitech 4 th period 2002.
XML: Extensible Markup Language
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. 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.
Database Management Systems, R. Ramakrishnan1 Introduction to Semistructured Data and XML Chapter 27, Part D Based on slides by Dan Suciu University of.
Agenda from now on Done: SQL, views, transactions, conceptual modeling, E/R, relational algebra. Starting: XML To do: the database engine: –Storage –Query.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
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.
Managing XML and Semistructured Data Lecture 8: Query Languages - XML-QL Prof. Dan Suciu Spring 2001.
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.
1 Lecture 10 XML Wednesday, October 18, XML Outline XML (4.6, 4.7) –Syntax –Semistructured data –DTDs.
QSX (LN 3)1 Query Languages for XML XPath XQuery XSLT (not being covered today!) (Slides courtesy Wenfei Fan, Univ Edinburgh and Bell Labs)
XQuery: 1 W3C (World Wide Web Consortium) What is W3C? –An industry consortium, best known for standardizing HTML and XML. –Working Groups create or adopt.
A Graphical Environment to Query XML Data with XQuery
Query Languages Aswin Yedlapalli. XML Query data model Document is viewed as a labeled tree with nodes Successors of node may be : - an ordered sequence.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 357 Database Systems I Query Languages for XML.
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.
XQuery – The W3C XML Query Language Jonathan Robie, Software AG Don Chamberlin, IBM Research Daniela Florescu, INRIA.
XML QUERY LANGUAGE Prepared by Prof. Zaniolo, Hung-chih Yang, Ling-Jyh Chen Modified by Fernando Farfán.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
Fundamentals, Design, and Implementation, 9/e Text and XML databases Instructor: Dragomir R. Radev Winter 2005.
XML, XML Schema, XPath and XQuery Query Languages CS561 Slides collated from several sources, including D. Suciu at Univ. of Washington.
1 Lecture 08: XML and Semistructured Data. 2 Outline XML (Section 17) –XML syntax, semistructured data –Document Type Definitions (DTDs) XPath.
Managing XML and Semistructured Data Lecture 2: XML Prof. Dan Suciu Spring 2001.
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.
XQuery Your gateway to manipulating XML in SQL Server 2005.
Xquery. Summary of XQuery FLWR expressions FOR and LET expressions Collections and sorting Resource W3C recommendation:
Introduction to XQuery Resources: Official URL: Short intros:
SDPL 20067: Querying XML with XQuery1 7 Querying XML n How to access data sources as XML? n XQuery, W3C XML Query Language –Candidate Rec, November 2005.
XML and XPath. Web Services: XML+XPath2 EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML origins: structured.
1 XML INTEROPERABILITY Manjusha Ravindranath. 2 CONTENTS Introduction Interoperability XSSQL syntax Usecases document Group By -Without aggregation -With.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
1 XTree for Declarative XML Querying Zhuo Chen, Tok Wang Ling, Mengchi Liu, and Gillian Dobbie January 2004.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
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.
Extensible Markup and Beyond
A Quilt, not a Camel Don Chamberlin Jonathan Robie Daniela Florescu May 19, 2000.
Introduction to XQuery Bun Yue Professor, CS/CIS UHCL.
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.
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.
1 XQuery Slides From Dr. Suciu. 2 XQuery Based on Quilt, which is based on XML-QL Uses XPath to express more complex queries.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
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.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
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.
XML: Extensible Markup Language
Querying and Transforming XML Data
Querying XML and Semistructured Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Semi-Structured data (XML Data MODEL)
Lecture 9: XML Monday, October 17, 2005.
XQuery Leonidas Fegaras.
Semi-Structured data (XML)
Presentation transcript:

Advisor: Prof. Zaniolo Hung-chih Yang Ling-Jyh Chen XML Query Language

Motivation As increasing amounts of information are stored, exchanged, and presented using XML, the ability to intelligently query XML data sources becomes increasingly important. One of the great strengths of XML is its flexibility in representing many different kinds of information from diverse sources. To exploit this flexibility, an XML query language must provide features for retrieving and interpreting information from these diverse sources.

Desiderata for an XML query language Expressive power Semantics Compositionality Schema Program manipulation

Different query languages for XML XPath & XQL: path expression syntax suitable for hierarchical documents XML-QL: binding variables and using bound variables to create new structures SQL: SELECT-FROM-WHERE pattern for restructuring data OQL: ODMG Quilt: accept a lot of advantages from above XML query languages, and it’s the immediate ancestor of XQuery

What’s XQuery Relational database SQL XML document /database XQuery

What’s XQuery (cont.) XQuery is designed to meet the requirements identified by the W3C XML Query Working Group “XML Query 1.0 Requirements” and the use cases in “XML Query Use Cases”. XQuery is designed to be a small, easily implementable language. XQuery is flexible enough to query a broad spectrum of XML information sources, including both databases and documents. XQuery defines a human-readable syntax for that language

What’s Xquery (cont.) The basic building block of XQuery is the expression XQuery is a functional language (at least the spec claimed it to be) XQuery is a strongly-typed language

XQuery vs XSLT Reinventing the Wheel? –XSLT is document-driven; XQuery is program driven –XSLT is written in XML; XQuery is not –An assertion (unproven): XSLT 2.0 can do everything XQuery can do

XQuery concepts A query in XQuery is an expression that: –Reads a number of XML documents or fragments –Returns a sequence of well-formed XML fragments

The principal forms of XQuery expressions Primary –The basic primitives of the language including literals, variables, function calls and the use of parentheses to control precedence of operation Path –Locates nodes within a tree, and returns a sequence of distinct nodes in document order Sequence –An ordered collection of zero or more items, where an item may be an atomic value or a node. An item is identical to a sequence of length one containing that item. Sequences are never nested.

The principal forms of XQuery expressions (cont.) Arithmetic –Xquery provides arithmetic operators for addition, subtraction, multiplication, division, and modulus. Comparison –Xquery provides four kinds of comparisons: value, general, node, and order comparisons. Logical –A logical expression is either an and-expression or an or-expression. The value of a logical expression is always one of the boolean values: true or false.

The principal forms of XQuery expressions (cont.) Contructor –Constructors can create XML structures within a query. There are constructors for elements, attributes, CDATA sections, processing instructions, and comments. FLWR –XQuery provides a FLWR expression for iteration and for binding variables to intermediate results. This kind of expression is often useful for computing joins between two or more documents and for restructuring data. The name "FLWR", pronounced "flower", stands for the keywords for, let, where, and return, the four clauses found in a FLWR expression.

The principal forms of XQuery expressions (cont.) Sorting –A sorting expression provides a way to control the order of items in a sequence. Conditional –XQuery supports a conditional expression based on the keywords if, then, and else. Quantified –Quantified expressions support existential and universal quantification. The value of a quantified expression is always true or false.

The principal forms of XQuery expressions (cont.) Datatypes –Runtime type checking and manipulation Validate –A validate expression validates its argument with respect to the in-scope schema definitions, using the schema validation process described in XML Schema.

XQuery Example 1 document("bib.xml")/bib/book[price = 39.95] Xquery: Find all books with a price of $39.95 Result: Data on the Web Abiteboul Serge Buneman Peter Suciu Dan Morgan Kaufmann Publishers 39.95

XQuery Example 2 < 1995]/title XQuery: Find the title of all books published before 1995 Result: TCP/IP Illustrated Advanced Programming in the Unix environment

XQuery Example 3 (for loop) { for $b in document("bib.xml")/bib/book where $b/publisher = "Addison-Wesley" and > 1991 return { $b/title } } XQuery: List books published by Addison-Wesley after 1991, including their year and title.

XQuery Example 3 (for loop) TCP/IP Illustrated Advanced Programming in the Unix environment Result:

XQuery Example 4 (Join) { for $b in document("bib.xml")//book, $a in document("reviews.xml")//entry where $b/title = $a/title return { $b/title } { $a/price } { $b/price } } XQuery: For each book found at both bn.com and amazon.com, list the title of the book and its price from each source.

XQuery Example 4 (Join) TCP/IP Illustrated Advanced Programming in the Unix environment Data on the Web Result:

XQuery Example 5 ( Grouping + quantifier ) { for $a in distinct-values(document("bib.com")//author) return { $a } { for $b in document(" where some $ba in $b/author satisfies deep-equal($ba,$a) return $b/title } } XQuery: For each author in the bibliography, list the author's name and the titles of all books by that author, grouped inside a "result" element.

XQuery Example 5 ( Grouping + quantifier ) Stevens W. TCP/IP Illustrated Advanced Programming in the Unix environment Abiteboul Serge Data on the Web …… Result:

XQuery Example 6 (Sorting) { for $b in document(" where $b/publisher = "Addison-Wesley" and > 1991 return { } { $b/title } sortby (title) } XQuery: List the titles and years of all books published by Addison- Wesley after 1991, in alphabetic order.

XQuery Example 6 (Sorting) Advanced Programming in the Unix environment TCP/IP Illustrated Result:

XQuery Example 7 (Recursion) define function one_level (element $p) returns element { { for $s in document("partlist.xml")//part where = return one_level($s) } } { for $p in return one_level($p) } XQuery: Convert the sample document from "partlist" format to "parttree" format.

XQuery Example 7 (Recursion) Result:

XQuery Example 8 (Sequence) for $s in document("report1.xml")//section[section.title = "Procedure"] return ($s//incision)[2]/instrument XQuery: In the Procedure section of Report1, what Instruments were used in the second Incision? Result: electrocautery

XQuery practice XML Query Language Demo, X-Hive. Another nice-looking online demo, Qexo: The GNU Kawa implementation of XQuery,

Conclusion XQuery is a simple substitution of XSLT, JSP, ASP, Servlet, CGI, PHP, etc. XQuery programs can accomplish most tasks of other tools aforementioned, and yet is much simplier to learn and easier to write. Possible direction is to extend XQuery for UPDATE and INSERT to an XML database Still lack of support from industry till now

Reference Jonathan Pinnock, et al. “Professional XML, 2 nd edition”, ISBN: , WROX Publishers, 2001 Serge Abiteboul, Peter Buneman and Dan Suciu, “Data on the Web: from Relations to Semistructured Data and XML”, ISBN X, Morgan Kaufmann Publishers, 2000 World Wide Web Consortium, “XQuery 1.0. An XML Query Language”, W3C Working Draft, Apr. 30, 2002 World Wide Web Consortium, “XML Path Language (XPath) Version 1.0”, W3C Recommendation, Nov. 16, 1999 Qexo: The GNU Kawa implementation of XQuery, XQuery Tutorial Don Chamberlin, Jonathan Robie, and Daniela Florescu, “Quilt: An XML Query Language for Heterogeneous Data Sources”, WebDB 2000, Dallas, May 2000