Session II Chapter 16 – XQuery

Slides:



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

IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
XML: Extensible Markup Language
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 Or, what about REAL databases?. XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer.
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?
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.
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.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
XMLII XSchema XSchema XQuery XQuery. XML Schema XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports XML.
Comparing XSLT and XQuery Michael Kay XTech 2005.
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.
Session II Chapter 2 – Chapter 2 – XSLhttp://
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.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
Company LOGO OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Session IV Chapter 9 – XML Schemas
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
XQL, OQL and SQL Xia Tang Sixin Qian Shijun Shen Feb 18, 2000.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
Nikos dimitrakas – IS4/2i1242/2i4042 spring XML Query Languages Database Systems (4th edition) Chapter 30.5, , Articles & Excerpts.
Unit 04 : XQuery COMP 5323 Web Database Technologies and Applications 2014.
XQuery Leah Andrews. Overview  Queries data stored in XML trees  Declarative  High-level  Functional (no side effects)  Strongly typed  Nodes 
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
XML and Database.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
CS 157B: Database Management Systems II February 20 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Subtract 1Subtract 3 Subtract same number Subtract numbers from their doubles Subtract 2.
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
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.
XQUERY The contents of this slide are obtained from various sources including, Wikipedia, W3School, Stanford website etc. January 2011 Dr.Kwanchai Eurviriyanukul.
Session IV Chapter 14 – Chapter 14 – XSLThttp://
Web Database Programming Using PHP
Query Languages for XML
XML: Extensible Markup Language
Unit 4 Representing Web Data: XML
Querying and Transforming XML Data
Web Database Programming Using PHP
Session IV Chapter 16 – XQuery
What is XLink? What is XPointer?
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Chapter 7 Representing Web Data: XML
Querying XML XQuery.
Querying XML XQuery.
Control Structures: if Conditional
Control Structures: for & while Loops
Chapter 4 Summary Query.
Session I Chapter 1 – Writing XML
PHP.
Querying XML XPath.
Session I Chapter 1 – Writing XML
Querying XML XPath.
2/18/2019.
The Selection Structure
INTRODUCTION to PERL PART 1.
Unit 6 - XML Transformations
Presentation transcript:

Session II Chapter 16 – XQuery http://www.profburnett.com CMP 051 XML Introduction Session II Chapter 16 – XQuery http://www.profburnett.com

Outline XQuery Introduction XQuery Functions Composing and XQuery Document Identifying a Source Document Using Path Expressions FLWOR Expression XQuery Syntax XQuery Functions Add Select Conditional Expressions User Defined Functions Joining Data Sources XQuery and Databases 8/1/2014 Copyright © Carl M. Burnett

XQuery Introduction XQuery is to XML what SQL is to database tables. XQuery is designed to query XML data Extract information to use in a Web Service Generate summary reports Transform XML data to XHTML Search Web documents for relevant information 8/1/2014 Copyright © Carl M. Burnett

Composing and XQuery Document xquery version "1.0"; "Hello World!" xquery version "1.0"; "Everyone count down:", reverse(1 to 10), "Blastoff!" xquery version "1.0"; <countdown>{reverse(1 to 10)}</countdown> 8/1/2014 Copyright © Carl M. Burnett

Identifying a Source Document xquery version "1.0"; doc("wonders-master.xml") 8/1/2014 Copyright © Carl M. Burnett

Using Path Expressions xquery version "1.0"; doc("wonders-master.xml")/ancient_wonders/wonder/location 8/1/2014 Copyright © Carl M. Burnett

FLWOR Expression FLWOR - "For, Let, Where, Order by, Return". “for” clause selects elements into a variable called $x. “where” clause selects only elements with a specified. “order” clause defines the sort-order. “return” clause specifies what should be returned. 8/1/2014 Copyright © Carl M. Burnett

FLWOR Expression Books.xml wonders-master.xml xquery version "1.0"; for $wndr in doc("wonders-master.xml")/ancient_wonders/wonder where contains($wndr/location, "Turkey") return $wndr/name Books.xml xquery version "1.0"; for $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return $x/title 8/1/2014 Copyright © Carl M. Burnett

XQuery Syntax 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 :) 8/1/2014 Copyright © Carl M. Burnett

XQuery Functions XQuery Conditional Expressions XQuery Comparisons 1. General comparisons: =, !=, <, <=, >, >= 2. Value comparisons: eq, ne, lt, le, gt, ge for $x in doc("books.xml")/bookstore/book return if ($x/@category="CHILDREN") then <child>{data($x/title)}</child> else <adult>{data($x/title)}</adult> $bookstore//book/@q > 10 $bookstore//book/@q gt 10 XQuery Functions 8/1/2014 Copyright © Carl M. Burnett

Joining Data Sources xquery version "1.0"; for $wndr in doc("wonders-master.xml")/ancient_wonders/wonder for $quake in doc("earthquake_data.xml")/earthquakes/occurrence where $quake[cities_affected/city = $wndr/location] return (data($wndr/name[@language='English']), data($quake/date)) 8/1/2014 Copyright © Carl M. Burnett

XQuery and Databases xquery version "1.0"; let $cntry_medals := collection("olympics.medals")/* let $total_gold := sum(data($cntry_medals/gold)) let $total_silver := sum(data($cntry_medals/silver)) let $total_bronze := sum(data($cntry_medals/bronze)) let $total_medals := $total_gold + $total_silver + $total_bronze return ( "Total gold medals awarded:", $total_gold, "Total silver medals awarded:", $total_silver, "Total bronze medals awarded:", $total_bronze, "Total medals awarded:", $total_medals ) 8/1/2014 Copyright © Carl M. Burnett

Review XQuery Introduction XQuery Functions Composing and XQuery Document Identifying a Source Document Using Path Expressions FLWOR Expression XQuery Syntax XQuery Functions Add Select Conditional Expressions User Defined Functions Joining Data Sources XQuery and Databases Next – Chapter 14 - XSLT 2.0 8/1/2014 Copyright © Carl M. Burnett