XQuery Or, what about REAL databases?. XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer.

Slides:



Advertisements
Similar presentations
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: C2.
Advertisements

XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
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.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 7. XQuery.
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
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.
XML and The Relational Data Model
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
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.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
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.
COP4540 Database Management System Final Review Reviewed by Ramakrishna. Parts of this are taken from Fernando Farfan’s presentation.
Introduction to XQuery Resources: Official URL: Short intros:
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
XML TECHNOLOGY FAMILY XML XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to describe data[carry data],
CSE3201/CSE4500 Information Retrieval Systems
XPath XPath is used to navigate through elements and attributes in an XML document. XPath is a major element in W3C's XSLT standard - and XQuery and XPointer.
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.
1 Querying XML Documents. 2 Objectives How XML generalizes relational databases The XQuery language How XML may be supported in databases.
1 XPath XPath became a W3C Recommendation 16. November 1999 XPath is a language for finding information in an XML document XPath is used to navigate through.
Session II Chapter 2 – Chapter 2 – XSLhttp://
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
28 October 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures Online support:
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Unit 04 : XQuery COMP 5323 Web Database Technologies and Applications 2014.
Database Systems Part VII: XML Querying Software School of Hunan University
Namespace information are represented as namespace node which maps in scope on an element Attach to every element node where namespace is declared root.
SQL-5 (Group By.. Having). Group By  Need: To apply the aggregate functions to subgroups of tuples in a relation, where the subgroups are based on some.
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.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
Dr. Chunbo Chu Week 3. XML Not a replacement for HTML. XML and HTML were designed with different goals: XML was designed to transport and store data,
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.
What is XLink? XLink is short for XML Linking Language XLink is used to create hyperlinks in XML documents Any element in an XML document can behave as.
IS432 Semi-Structured Data Lecture 6: XQuery Dr. Gamal Al-Shorbagy.
IS432 Semi-Structured Data Lecture 4: XPath Dr. Gamal Al-Shorbagy.
XML TECHNOLOGY FAMILY UNIT - I XML XML - Introduction.
Lecture 17: XPath and XQuery Wednesday, Nov. 7, 2001.
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
XQUERY The contents of this slide are obtained from various sources including, Wikipedia, W3School, Stanford website etc. January 2011 Dr.Kwanchai Eurviriyanukul.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
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. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data.
XML Query languages--XPath. Objectives Understand XPath, and be able to use XPath expressions to find fragments of an XML document Understand tree patterns,
XML: Extensible Markup Language
Querying and Transforming XML Data
Session IV Chapter 16 – XQuery
What is XLink? What is XPointer?
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML stands for Extensible Markup Language.
Querying XML XQuery.
Querying XML XQuery.
Querying XML XPath.
Querying XML XPath.
2/18/2019.
Session II Chapter 16 – XQuery
Presentation transcript:

XQuery Or, what about REAL databases?

XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer

Path expressions in XQuery The following path expression is used to select all the title elements in the "books.xml" file:books.xml doc("books.xml")/bookstore/book/title (/bookstore selects the bookstore element, /book selects all the book elements under the bookstore element, and /title selects all the title elements under each book element) The XQuery above will extract the following: Everyday Italian Harry Potter XQuery Kick Start Learning XML

Some basic syntax rules of XQuery XQuery is case-sensitive XQuery elements, attributes, and variables must be valid XML names An XQuery string value can be in single or double quotes An XQuery variable is defined with a $ followed by a name, e.g. $bookstore XQuery comments are delimited by (: and :), e.g. (: XQuery Comment :)

Predicates XQuery uses predicates to limit the extracted data from XML documents. The following predicate is used to select all the book elements under the bookstore element that have a price element with a value that is less than 30: doc("books.xml")/bookstore/book[price<30] The XQuery above will extract the following: Harry Potter J K. Rowling

Using FLWOR Look at the following path expression: doc("books.xml")/bookstore/book[price>30]/title The expression above will select all the title elements under the book elements that is under the bookstore element that have a price element with a value that is higher than 30. The following FLWOR expression will select exactly the same as the path expression above: for $x in doc("books.xml")/bookstore/book where $x/price>30 return $x/title The result will be: XQuery Kick Start Learning XML

FLWOR FLWOR is the main engine of XQuery: For-Let-Where-Order-Return (pronounced "flower") generalizes SELECT-FROM-HAVING-WHERE from SQL for $d in document("depts.xml")//deptno let $e := document("emps.xml")//employee[deptno = $d] where count($e) >= 10 order by avg($e/salary) descending return { $d, {count($e)}, {avg($e/salary)} } for generates an ordered list of bindings of deptno values to $d let associates to each binding a further binding of the list of emp elements with that department number to $e. A t this stage, we have an ordered list of tuples of bindings: ($d,$e) where filters that list to retain only the desired tuples order sorts that list by the given criteria return constructs for each tuple a resulting value The combined result is in this case a list of departments with at least 10 employees, sorted by average salaries.

Sorting with FLWOR With FLWOR you can sort the result: for $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return $x/title The for clause selects all book elements under the bookstore element into a variable called $x. The where clause selects only book elements with a price element with a value greater than 30. The order by clause defines the sort-order. Will be sorted by the title element. The return clause specifies what should be returned. Here it returns the title elements. The result of the XQuery expression above will be: Learning XML XQuery Kick Start

FLWOR and HTML Now we want to list all the book-titles in our bookstore in an HTML list. We add and tags to the FLWOR expression, and we want to eliminate the title element, and show only the data inside the title element: { for $x in doc("books.xml")/bookstore/book/title order by $x return {data($x}) } The result of the above will be: Everyday Italian Harry Potter Learning XML XQuery Kick Start

Extracting attributes Bookstore { for $x in doc("books.xml")/bookstore/book order by $x/title return {data($x/title)}. Category: } The XQuery expression above will generate the following result: Bookstore Everyday Italian. Category: COOKING Harry Potter. Category: CHILDREN Learning XML. Category: WEB XQuery Kick Start. Category: WEB

XQuery Conditional Expressions "If-Then-Else" expressions are allowed in XQuery. Look at the following example: for $x in doc("books.xml")/bookstore/book return if then {data($x/title)} else {data($x/title)} The result of the example above will be: Everyday Italian Harry Potter Learning XML XQuery Kick Start