Session IV Chapter 16 – XQuery

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XQuery.
XML: Extensible Markup Language
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
XSLT (eXtensible Stylesheet Language Transformation) 1.
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?
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
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.
XQL (XML Query Language) Jonathan Robie (Software AG) Eduard Derksen (CSCIO) Peter Fankhauser (GMD-IPSI) Ed Howland (DEGA) Gerald Huck (GMD-IPSI) Ingo.
1 COS 425: Database and Information Management Systems XML and information exchange.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
XMLII XSchema XSchema XQuery XQuery. XML Schema XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports XML.
4/20/2017.
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.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
WORKING WITH XSLT AND XPATH
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.
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,
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Session IV Chapter 9 – XML Schemas
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.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Utilizing XML in ColdFusion MX by Attila Domokos.
Date : 3/3/2010 Web Technology Solutions Class: Application Syndication: Parse and Publish RSS & XML Data.
Nikos dimitrakas – IS4/2i1242/2i4042 spring XML Query Languages Database Systems (4th edition) Chapter 30.5, , Articles & Excerpts.
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.
XML and Database.
CS 157B: Database Management Systems II February 20 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
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://
Unit 5 - Cascading Style Sheets (CSS) XML - Level I Basic.
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.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
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
XML: Extensible Markup Language
Unit 4 Representing Web Data: XML
Querying and Transforming XML Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Database Processing with XML
YQL Kevin Murphy CMPS 183.
Session II Chapter 2 - XSLT
Chapter 7 Representing Web Data: XML
Querying XML XQuery.
JavaScript an introduction.
Querying XML XQuery.
PHP.
2/18/2019.
ITI 239 HTML5 Desktop and Mobile Level I
The Selection Structure
Session II Chapter 16 – XQuery
INTRODUCTION to PERL PART 1.
Course Review HTML5 Level I Course Review
Unit 6 - XML Transformations
Presentation transcript:

Session IV Chapter 16 – XQuery http://www.profburnett.com CMP 051 XML Introduction Session IV 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 "3.0"; declare namespace ext="http://www.altova.com/xslt-extensions"; "Hello World!" xquery version "3.0"; declare namespace ext="http://www.altova.com/xslt-extensions"; "Everyone count down:", reverse(1 to 10), "Blastoff!" xquery version "3.0"; declare namespace ext="http://www.altova.com/xslt-extensions"; <countdown>{reverse(1 to 10)}</countdown> 8/1/2014 Copyright © Carl M. Burnett

Identifying a Source Document xquery version "3.0"; declare namespace ext="http://www.altova.com/xslt-extensions"; doc ("C:\Student_Exercises\Session_2_Exercise_1\2016_Female_Songs_of_the_Year.xml") 8/1/2014 Copyright © Carl M. Burnett

Using Path Expressions xquery version "3.0"; declare namespace ext="http://www.altova.com/xslt-extensions"; doc ("C:\Student_Exercises\Session_2_Exercise_1\2016_Female_Songs_of_the_Year.xml") /DocumentElement/Song 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 8/1/2014 Copyright © Carl M. Burnett 2016_Female_Songs_of_the_Year.xml xquery version "3.0"; declare namespace ext="http://www.altova.com/xslt-extensions"; for $album_song in ("C:\Student_Exercises\Session_2_Exercise_1\2016_Female_Songs_of_the_Year.xml") /DocumentElement/Song let $songt := $album_song /Track_Name where contains ($album_song /Artist_Name, "Birdy") order by $album_song /Album_Name return 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

Student Exercise 1 Create a XQuery for the 2016 Female Songs of the Year.xml file using Altova XMLSpy. Preview Transformed XQuery Output.XML file in browser. Link XQuery files to your webpage. FLOWR Xquery (.xqu) File XQuery Output.XML file Post to live server. Preview on live site. 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