XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau

Size: px
Start display at page:

Download "XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau"

Transcription

1 XML Query Languages Yanlei Diao UMass Amherst April 22, 2008 Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau 1

2 Querying XML How do you query a directed graph? a tree? A common approach: define some sort of a template describing traversals from the root of the directed graph. In XML, the basis of this template is XPath. XPath navigates through the tree to select data. The complete query language is XQuery. XQuery both selects data and constructs output. 2

3 XML Path Language (XPath) 1.0 XPath 1.0: Navigates through hierarchical XML document structure Applies selection conditions Retrieves nodes Input: a tree of nodes Node type: Document, Element, Attribute, Text Output: often a set of nodes An ordered language It can query in an order-aware fashion. It always returns nodes in document order. 3

4 Sample Data for Queries <bib> <book> <publisher> Addison-Wesley </publisher> <author> Serge Abiteboul </author> <author> <first-name> Rick </first-name> <last-name> Hull </last-name> </author> <author> Victor Vianu </author> <title> Foundations of Databases </title> <year> 1995 </year> </book> <book price= 55 > <publisher> Freeman </publisher> <author> Jeffrey D. Ullman </author> <title> Principles of Database and Knowledge Base Systems </title> <year> 1998 </year> </book> </bib> 4

5 Data Model for XPath Ordered Tree: ordered among element and text nodes; unordered among attribute nodes bib Document Node Element Node book book Attribute Node publisher author author author... price... Text Node Addison- Wesley Serge Abiteboul first Rick last Kull Victor Vianu 50 5

6 XPath: Simple Expressions /bib/book/year child operator / Result: <year> 1995 </year> <year> 1998 </year> /bib/paper/year Result: empty (there were no papers) /bib/(book paper)/year OR operator 6

7 XPath: Restricted Kleene Closure //author Result:<author> Serge Abiteboul </author> <author> <first-name> Rick </first-name> <last-name> Hull </last-name> </author> <author> Victor Vianu </author> <author> Jeffrey D. Ullman </author> /bib//first-name descendant operator // Result: <first-name> Rick </first-name> 7

8 XPath: Text Nodes /bib/book/author/text() Result: Serge Abiteboul Victor Vianu Jeffrey D. Ullman Rick Hull doesn t appear because he has firstname, lastname elements. 8

9 XPath: Wildcard //author/* Result: <first-name> Rick </first-name> <last-name> Hull </last-name> * Matches any element name 9

10 XPath: Attribute Nodes Result: means that price has to be an attribute 10

11 XPath: Predicates Positional predicate /bib/book/author[1] Result: <author> Serge Abiteboul </author> <author> Jeffrey D. Ullman </author> 11

12 XPath: Predicates Predicate using a nested path expression /bib/book/author[first-name] Result: <author> <first-name> Rick </first-name> <last-name> Hull </last-name> </author> /bib/book/author[first-name = Rick ] 12

13 XPath: More Predicates More nested paths. operator /bib/book/author[firstname][address[city][.//zip]]/lastname Result: <lastname> </lastname> <lastname> </lastname> [./city] 13

14 XPath: Summary /bib matches a bib element under root /bib/paper matches a paper in bib /bib/* matches any child element in bib /bib//paper matches a paper in bib, at any depth //paper matches a paper at any depth //(paper book) matches a paper or a book /bib/book/@price matches price attribute in book, in bib /bib/book[@price<60]/author matches an author of a book costing less than $60, in bib /bib/book/author[1]/lastname matches the lastname of the first author of each book in bib /bib/book/author[lastname] matches an author with a lastname in each book in bib 14

15 XQuery 1.0 XQuery: the SQL for XML. A full programming language that can retrieve fragments from XML transform XML data to XML data in arbitrary ways Currently being widely used for querying XML data sets routing and transforming XML messages in Web services creating logical views in data integration 15

16 XQuery Data Model Instance of the data model: a sequence composed of zero or more items Item: node or atomic value Node: document element attribute text namespace processing instruction comment Atomic value: an indivisible value, e.g., string, boolean, ID, IDREF, decimal, URI,

17 XML nodes XML nodes: have unique node identifiers. have children and an optional parent (conceptually a tree ). are ordered based of the topological order in the tree ( document order ). Nodes can be compared directly by: (i) identity, (ii) document order, or (iii) value (after converted from node to value, explicitly using data() or implicitly) 17

18 XQuery Expressions XQuery Expr := Constants Variable FunctionCalls ComparisonExpr ArithmeticExpr LogicExpr PathExpr FLWORExpr ConditionalExpr QuantifiedExpr TypeSwitchExpr InstanceofExpr CastExpr UnionExpr IntersectExceptExpr ConstructorExpr ValidateExpr Expressions can be nested with full generality! Functional programming heritage. 18

19 Examples of Path Expressions doc( bibliography.xml )/bib $x/bib/book/year $x/chapter[figure] $x//author $x/book/chapter[5]/section[2] 19

20 Simple Iteration Expression Syntax : for variable in expression1 return expression2 e.g. for $x in doc( bib.xml )/bib/book return $x/title Semantics: bind the variable $x to each node returned by expression1 for each such binding, evaluate expression2 concatenate the resulting sequences 20

21 FLWOR expressions FLWOR (For-Let-Where-Order by-return) is a high-level construct that selects data and further restructures data for output: for $x in expression1 /* similar to FROM in SQL */ [let $y := expression2 ] /* no analogy in SQL */ [where expression3 ] /* similar to WHERE in SQL */ [order by expression4 (ascending descending)? (empty (greatest least))? ] /* similar to ORDER BY in SQL */ return expression5 /* similar to SELECT in SQL */ 21

22 Example FLOWR Expression for $x in doc( bib.xml )/bib/book // iterate, bind each item to $x let $y := $x/author // no iteration, bind a sequence to $y where $x/title= XML // filter each tuple ($x, $y) order by $x/@year descending // order tuples return count($y) // one result per surviving tuple The for clause iterates over all books, binding $x to each book in turn. For each binding of $x, the let clause binds $y to all authors of this book. The result of for and let clauses is a tuple stream in which each tuple contains a pair of bindings for $x and $y, i.e. ($x, $y). The where clause filters each tuple ($x, $y) by checking predicates. The order by clause orders surviving tuples. The return clause returns the count of $y for each surviving tuple. 22

23 FOR versus LET for $x in doc("bib.xml")/bib/book return <result> $x </result> let $x := doc("bib.xml")/bib/book return <result> $x </result> Returns: <result><book>...</book></result> <result><book>...</book></result> <result><book>...</book></result>... Returns: <result> <book>...</book> <book>...</book> <book>...</book>... </result> 23

24 Getting Distinct Values from FOR Distinct values: The for expression evaluates to a sequence of nodes. The fn:distinct-values function converts nodes to atomic values and removes duplicates. for $a in doc( bib.xml )/book/author return $a versus for $a in distinct-values(doc( bib.xml )/book/author) return <author-name> {$a} </author-name> 24

25 More Examples of WHERE Selection conditions for $b in doc("bib.xml")/bib/book where $b/publisher = Addison Wesley" and $b/@year = 1998 return $b/title for $b in doc("bib.xml")/bib/book where empty($b/author) return $b/title for $b in doc("bib.xml")/bib/book where count($b/author) = 1 return $b/title Aggregates over a sequence: count, avg, sum, min, max 25

26 General Comparisons General comparison operators (=,!=, <, >, <=, >=): Existentially quantified comparisons, applied to operand sequences of any length. Comparison is true if one value from a sequence satisfies the comparison. for $b in doc( bib.xml )/bib/book where $b/author = JefferyUllman return $b/author (1, 2) = (2, 3)? 26

27 Value Comparisons Value comparisons (eq, ne, lt, le, gt, ge): Used to compare single values. If the left (right) operand does not carry a single value, a runtime error is thrown. for $b in doc( bib.xml )/bib/book where $b/author eq JefferyUllman return $b/author 27

28 Node Comparisons Node comparison by identity: for $b in doc( bib.xml )/bib/book where $b/author[last = Ullman ] is $b/author[first = Jeffery ] return $b/title Node comparison by document order: for $b in doc( bib.xml )/bib/book where $b/author[. = JefferyUllman ] << $b/author[. = JenniferWidom ] return $b/title 28

29 String Operations Functions for string matching fn:contains(xs:string, xs:string) fn:starts-with(xs:string, xs:string) fn:ends-with(xs:string, xs:string) fn:substring-before(xs:string, xs:string) fn:substring-after(xs:string, xs:string) fn:matches($input as xs:string, $pattern as xs:string) for $a in doc( bib.xml )//author where contains($a, Ullman") return $a Use all data of $a (i.e., all descendant text nodes)! <author> <name>jeffery Ullman</name> </author> <author> <first>jeffery</first> <last>ullman</last> </author> 29

30 Joins in XQuery Joins A tuple here is ($b, $p), a unique combination of bindings of $b, $p. for $b in doc( bib.xml )//book, $p in doc( publishers.xml")//publisher where $b/publisher = $p/name return ($b/title, $p/name, $p/address) 30

31 Node Constructors Node constructor: constructs new nodes elements, attributes, text, documents, processing instructions, comments.. Direct element constructor: a form of element constructor in which the element name is a constant <book isbn="isbn "> <title>harold and the Purple Crayon</title> <author> <first>crockett</first> <last>johnson</last> </author> </book> 31

32 Element Construction in RETURN for $p in doc( report.xml )//person return ( <result> first person is Bob /* literal */ </result>, <result> { $p/name } /* {evaluated content} */ </result>, <result> { $p/name/text()} </result>, <result> Yesterday {$p/name} visited us. </result> ) Braces "{ }" are used to delimit enclosed expressions, which will be evaluated and replaced by their values. If return has > 1 top element, use ( ) and comma operator. 32

33 More on Element Construction Elements may contain attributes. Value of an attribute can be: a string of characters enclosed in quotes, e.g., <book year= 2005 > evaluated using enclosed expressions specified in { } <bib> { for $b in doc("bib.xml")/bib/book where $b/publisher = "Addison-Wesley" and $b/@year > 1991 return <book year="{ $b/@year }"> { $b/title } </book> } </bib> The largest wrapping tag creates well-formed XML. 33

34 Nested FLWOR <author_list> { for $a in distinct-values(doc( bib.xml )/book/author) order by $a return <author> <name> {$a} </name> <books> { for $b in doc( bib.xml )/book[author = $a] order by $b/title return $b/title } </books> </author> } </author_list> The nested FLOWR effectively implements group books by author. No Group By in XQuery! 34

Introduction to Database Systems CSE 444

Introduction to Database Systems CSE 444 Introduction to Database Systems CSE 444 Lecture 25: XML 1 XML Outline XML Syntax Semistructured data DTDs XPath Coverage of XML is much better in new edition Readings Sections 11.1 11.3 and 12.1 [Subset

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 11: XML and XPath 1 XML Outline What is XML? Syntax Semistructured data DTDs XPath 2 What is XML? Stands for extensible Markup Language 1. Advanced, self-describing

More information

Querying XML Data. Querying XML has two components. Selecting data. Construct output, or transform data

Querying XML Data. Querying XML has two components. Selecting data. Construct output, or transform data Querying XML Data Querying XML has two components Selecting data pattern matching on structural & path properties typical selection conditions Construct output, or transform data construct new elements

More information

Lecture 11: Xpath/XQuery. Wednesday, April 17, 2007

Lecture 11: Xpath/XQuery. Wednesday, April 17, 2007 Lecture 11: Xpath/XQuery Wednesday, April 17, 2007 1 Outline XPath XQuery See recommend readings in previous lecture 2 Querying XML Data XPath = simple navigation through the tree XQuery = the SQL of XML

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 16: Xpath, XQuery, JSON 1 Announcements Homework 4 due on Wednesday There was a small update on the last question Webquiz 6 due on Friday Midterm will be

More information

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 13: XML and XPath 1 Announcements Current assignments: Web quiz 4 due tonight, 11 pm Homework 4 due Wednesday night, 11 pm Midterm: next Monday, May 4,

More information

10/24/12. What We Have Learned So Far. XML Outline. Where We are Going Next. XML vs Relational. What is XML? Introduction to Data Management CSE 344

10/24/12. What We Have Learned So Far. XML Outline. Where We are Going Next. XML vs Relational. What is XML? Introduction to Data Management CSE 344 What We Have Learned So Far Introduction to Data Management CSE 344 Lecture 12: XML and XPath A LOT about the relational model Hand s on experience using a relational DBMS From basic to pretty advanced

More information

XPath an XML query language

XPath an XML query language XPath an XML query language Some XML query languages: XML-QL XPath XQuery Many others 1 XML-QL http://www.w3.org/tr/note-xml-ql (8/98) Features: regular path expressions patterns, templates Skolem Functions

More information

Traditional Query Processing. Query Processing. Meta-Data for Optimization. Query Optimization Steps. Algebraic Transformation Predicate Pushdown

Traditional Query Processing. Query Processing. Meta-Data for Optimization. Query Optimization Steps. Algebraic Transformation Predicate Pushdown Traditional Query Processing 1. Query optimization buyer Query Processing Be Adaptive SELECT S.s FROM Purchase P, Person Q WHERE P.buyer=Q. AND Q.city= seattle AND Q.phone > 5430000 2. Query execution

More information

Introduction to Semistructured Data and XML. Management of XML and Semistructured Data. Path Expressions

Introduction to Semistructured Data and XML. Management of XML and Semistructured Data. Path Expressions Introduction to Semistructured Data and XML Chapter 27, Part E Based on slides by Dan Suciu University of Washington Database Management Systems, R. Ramakrishnan 1 Management of XML and Semistructured

More information

EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML

EXtensible Markup Language (XML)   a W3C standard to complement HTML A markup language much like HTML XML and XPath EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML origins: structured text SGML motivation: HTML describes presentation XML describes content

More information

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1 XQuery Leonidas Fegaras University of Texas at Arlington Web Databases and XML L7: XQuery 1 XQuery Influenced by SQL Based on XPath Purely functional language may access elements from documents, may construct

More information

XQuery. Announcements (March 21) XQuery. CPS 216 Advanced Database Systems

XQuery. Announcements (March 21) XQuery. CPS 216 Advanced Database Systems XQuery CPS 216 Advanced Database Systems Announcements (March 21) 2 Midterm has been graded Homework #3 will be assigned next Tuesday Reading assignment due next Wednesday XML processing in Lore (VLDB

More information

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 14: XQuery, JSON 1 Announcements Midterm: Monday in class Review Sunday 2 pm, SAV 264 Includes everything up to, but not including, XML Closed book, no

More information

Outline of the Presentation. Querying XML. A little bit of history. What is XML? XML Data Example (2) XML Data Example (1)

Outline of the Presentation. Querying XML. A little bit of history. What is XML? XML Data Example (2) XML Data Example (1) T H E 8 T H A N N U A L B E A T E C H N O L O G Y C O N F E R E N C E Outline of the Presentation Querying XML Daniela Florescu BEA Systems danielaf@bea.com What is XML? XML query language : the big picture

More information

Introduction to XML. Yanlei Diao UMass Amherst April 17, Slides Courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives and Gerome Miklau.

Introduction to XML. Yanlei Diao UMass Amherst April 17, Slides Courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives and Gerome Miklau. Introduction to XML Yanlei Diao UMass Amherst April 17, 2008 Slides Courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives and Gerome Miklau. 1 Structure in Data Representation Relational data is highly

More information

Big Data Exercises. Fall 2016 Week 9 ETH Zurich

Big Data Exercises. Fall 2016 Week 9 ETH Zurich Big Data Exercises Fall 2016 Week 9 ETH Zurich Introduction This exercise will cover XQuery. You will be using oxygen (https://www.oxygenxml.com/xml_editor/software_archive_editor.html), AN XML/JSON development

More information

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018 XPath and XQuery Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue. Oct. 23) Homework #3 due in two weeks Project milestone #1 feedback : we are a bit behind, but will definitely release

More information

XML Parsers XPath, XQuery

XML Parsers XPath, XQuery XML Parsers XPath, XQuery Lecture 10 1 XML parsers XPath XQuery XML publishing Outline Background (reading) http://www.w3.org/tr/xmlquery-use-cases/ several Xquery examples http://www.xmlportfolio.com/xquery.html

More information

In this lecture. FLWR expressions FOR and LET expressions Collections and sorting

In this lecture. FLWR expressions FOR and LET expressions Collections and sorting In this lecture Summary of XQuery Resources FLWR expressions FOR and LET expressions Collections and sorting XQuery: A Query Language for XML Chamberlin, Florescu, et al. W3C recommendation: www.w3.org/tr/xquery/

More information

XML and Semi-structured data

XML and Semi-structured data What is XML? Text annotation/markup language ( extensible Markup Language) XML and Semi-structured data Rich Feynman

More information

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar..

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. Overview Introduction to XQuery XQuery is an XML query language. It became a World Wide Web Consortium Recommendation in January 2007,

More information

Data Services (II): XML Transformation and Query Techniques

Data Services (II): XML Transformation and Query Techniques Data Services (II): XML Transformation and Query Techniques Helen Paik School of Computer Science and Engineering University of New South Wales Week 9 H. Paik (CSE, UNSW) XML Week 9 1 / 50 Part I XQuery

More information

Introduction to Semistructured Data and XML

Introduction to Semistructured Data and XML Introduction to Semistructured Data and XML Chapter 27, Part D Based on slides by Dan Suciu University of Washington Database Management Systems, R. Ramakrishnan 1 How the Web is Today HTML documents often

More information

Big Data 12. Querying

Big Data 12. Querying Ghislain Fourny Big Data 12. Querying pinkyone / 123RF Stock Photo Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath COSC 304 Introduction to Database Systems XML Querying Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Querying XML We will look at two standard query languages: XPath

More information

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model.

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model. Semi-structured data (SSD) XML Semistructured data XML, DTD, (XMLSchema) XPath, XQuery More flexible data model than the relational model. Think of an object structure, but with the type of each object

More information

Lab Assignment 3 on XML

Lab Assignment 3 on XML CIS612 Dr. Sunnie S. Chung Lab Assignment 3 on XML Semi-structure Data Processing: Transforming XML data to CSV format For Lab3, You can write in your choice of any languages in any platform. The Semi-Structured

More information

Query Languages for XML

Query Languages for XML Query Languages for XML XPath XQuery 1 The XPath/XQuery Data Model Corresponding to the fundamental relation of the relational model is: sequence of items. An item is either: 1. A primitive value, e.g.,

More information

Why do we need an XML query language? XQuery: An XML Query Language CS433. Acknowledgment: Many of the slides borrowed from Don Chamberlin.

Why do we need an XML query language? XQuery: An XML Query Language CS433. Acknowledgment: Many of the slides borrowed from Don Chamberlin. Why do we need an XML query language? XQuery: n XML Query Language S433 cknowledgment: Many of the slides borrowed from Don hamberlin XML emerging as dominant standard for data representation and exchange

More information

Progress Report on XQuery

Progress Report on XQuery Progress Report on XQuery Don Chamberlin Almaden Research Center May 24, 2002 History Dec. '98: W3C sponsors workshop on XML Query Oct. '99: W3C charters XML Query working group Chair: Paul Cotton About

More information

Querying XML Documents. Organization of Presentation

Querying XML Documents. Organization of Presentation Querying XML Documents Paul Cotton, Microsoft Canada University of Waterloo Feb 1, 2002 1 Organization of Presentation XML query history XML Query WG history, goals and status XML Query working drafts

More information

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while 1 One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while leaving the engine to choose the best way of fulfilling

More information

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9 XML databases Jan Chomicki University at Buffalo Jan Chomicki (University at Buffalo) XML databases 1 / 9 Outline 1 XML data model 2 XPath 3 XQuery Jan Chomicki (University at Buffalo) XML databases 2

More information

Introduction to Semistructured Data and XML. Overview. How the Web is Today. Based on slides by Dan Suciu University of Washington

Introduction to Semistructured Data and XML. Overview. How the Web is Today. Based on slides by Dan Suciu University of Washington Introduction to Semistructured Data and XML Based on slides by Dan Suciu University of Washington CS330 Lecture April 8, 2003 1 Overview From HTML to XML DTDs Querying XML: XPath Transforming XML: XSLT

More information

Big Data 10. Querying

Big Data 10. Querying Ghislain Fourny Big Data 10. Querying pinkyone / 123RF Stock Photo 1 Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

References. Xquery Tutorial. Availability. Xquery Overview. Example XML Document: bib.xml. Advice: Example XML Document: bib.xml

References. Xquery Tutorial. Availability. Xquery Overview. Example XML Document: bib.xml. Advice: Example XML Document: bib.xml References Xquery Tutorial Dan Goldberg & Craig Knoblock University of Southern California XQuery 1.0: An XML Query Language www.w3.org/tr/xquery/ XML Query Use Cases www.w3.org/tr/xmlquery-use-cases What

More information

Advanced Database Technologies XQuery

Advanced Database Technologies XQuery Advanced Database Technologies XQuery Christian Grün Database & Information Systems Group Introduction What is XQuery? query language (more than a) counterpart to SQL functional language general purpose

More information

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 14-15: XML CSE 414 - Spring 2013 1 Announcements Homework 4 solution will be posted tomorrow Midterm: Monday in class Open books, no notes beyond one hand-written

More information

An Algebra for XML Query

An Algebra for XML Query An Algebra for XML Query Mary Fernández AT&T Labs Research mff@research.att.com Jérôme Siméon Bell Labs, Lucent Technologies simeon@research.bell-labs.com Philip Wadler Bell Labs, Lucent Technologies wadler@research.bell-labs.com

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 12: XQuery 1 XQuery Standard for high-level querying of databases containing data in XML form Based on Quilt, which is based on XML-QL Uses XPath to express

More information

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p:// TDDD43

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p://  TDDD43 Theme 1.2: XML query languages Fang Wei- Kleiner h?p://www.ida.liu.se/~ Query languages for XML Xpath o Path expressions with conditions o Building block of other standards (XQuery, XSLT, XLink, XPointer,

More information

XML in Databases. Albrecht Schmidt. al. Albrecht Schmidt, Aalborg University 1

XML in Databases. Albrecht Schmidt.   al. Albrecht Schmidt, Aalborg University 1 XML in Databases Albrecht Schmidt al@cs.auc.dk http://www.cs.auc.dk/ al Albrecht Schmidt, Aalborg University 1 What is XML? (1) Where is the Life we have lost in living? Where is the wisdom we have lost

More information

XML and information exchange. XML extensible Markup Language XML

XML and information exchange. XML extensible Markup Language XML COS 425: Database and Information Management Systems XML and information exchange 1 XML extensible Markup Language History 1988 SGML: Standard Generalized Markup Language Annotate text with structure 1992

More information

Katz_C01.qxd 7/23/03 2:45 PM Page 1. Part I BASICS

Katz_C01.qxd 7/23/03 2:45 PM Page 1. Part I BASICS Katz_C01.qxd 7/23/03 2:45 PM Page 1 Part I BASICS Katz_C01.qxd 7/23/03 2:45 PM Page 2 Katz_C01.qxd 7/23/03 2:45 PM Page 3 Chapter 1 XQUERY: A GUIDED TOUR Jonathan Robie XML (Extensible Markup Language)

More information

XML Overview COMP9319

XML Overview COMP9319 XML Overview COMP9319 Raymond Wong XML XML (extensible Markup Language) is a standard developed by W3C (World Wide Web Consortium) and endorsed by a host of industry heavyweights such as IBM, Microsoft,

More information

Information Systems. XQuery. Nikolaj Popov

Information Systems. XQuery. Nikolaj Popov Information Systems XQuery Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at What Is XQuery The purpose of XQuery is to provide

More information

Chapter 1: Semistructured Data Management XML

Chapter 1: Semistructured Data Management XML Chapter 1: Semistructured Data Management XML XML - 1 The Web has generated a new class of data models, which are generally summarized under the notion semi-structured data models. The reasons for that

More information

Author: Irena Holubová Lecturer: Martin Svoboda

Author: Irena Holubová Lecturer: Martin Svoboda A7B36XML, AD7B36XML XML Technologies Lecture 4 XPath, SQL/XML 24. 3. 2017 Author: Irena Holubová Lecturer: Martin Svoboda http://www.ksi.mff.cuni.cz/~svoboda/courses/2016-2-a7b36xml/ Lecture Outline XPath

More information

Lecture 12: XQuery. Friday, February 3, Sorting in XQuery

Lecture 12: XQuery. Friday, February 3, Sorting in XQuery Lecture 12: XQuery Friday, February 3, 2006 1 Sorting in XQuery FOR $b $bin INdocument("bib.xml")//book[publisher = M.K ] ORDER BY $b/price/text() RETURN { $b/title,, $b/price }

More information

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data Pre-Discussion XQuery: An XML Query Language D. Chamberlin After the presentation, we will evaluate XQuery. During the presentation, think about consequences of the design decisions on the usability of

More information

Module 4. Implementation of XQuery. Part 1: Overview of Compiler, Runtime System

Module 4. Implementation of XQuery. Part 1: Overview of Compiler, Runtime System Module 4 Implementation of XQuery Part 1: Overview of Compiler, Runtime System Now let us talk XQuery Compile Time + Optimizations Operator Models Query Rewrite Runtime + Query Execution XML Data Representation

More information

A Quilt, not a Camel. Don Chamberlin Jonathan Robie Daniela Florescu. May 19, 2000

A Quilt, not a Camel. Don Chamberlin Jonathan Robie Daniela Florescu. May 19, 2000 A Quilt, not a Camel Don Chamberlin Jonathan Robie Daniela Florescu May 19, 2000 The Web Changes Everything All kinds of information can be made available everywhere, all the time XML is the leading candidate

More information

Chapter 1: Semistructured Data Management XML

Chapter 1: Semistructured Data Management XML Chapter 1: Semistructured Data Management XML 2006/7, Karl Aberer, EPFL-IC, Laboratoire de systèmes d'informations répartis XML - 1 The Web has generated a new class of data models, which are generally

More information

XML and XQuery. Susan B. Davidson. CIS 700: Advanced Topics in Databases MW 1:30-3 Towne 309

XML and XQuery. Susan B. Davidson.  CIS 700: Advanced Topics in Databases MW 1:30-3 Towne 309 XML and XQuery Susan B. Davidson CIS 700: Advanced Topics in Databases MW 1:30-3 Towne 309 http://www.cis.upenn.edu/~susan/cis700/homepage.html 2017 A. Alawini, S. Davidson XML Anatomy

More information

Introduction to XQuery and XML Databases

Introduction to XQuery and XML Databases Introduction to XQuery and XML Databases TEI@Oxford July 2009 XQuery While XSLT is good for transforming XML to other formats (XML, HTML, PDF, Text, etc.) sometimes you may wish to query a large database

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views 1. (4 points) Of the following statements, identify all that hold about architecture. A. DoDAF specifies a number of views to capture different aspects of a system being modeled Solution: A is true: B.

More information

Outline of this part (I) Part IV. Querying XML Documents. Querying XML Documents. Outline of this part (II)

Outline of this part (I) Part IV. Querying XML Documents. Querying XML Documents. Outline of this part (II) Outline of this part (I) Part IV Querying XML Documents Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2007/08 164 8 XPath Navigational access to XML documents Overview Context Location steps Navigation

More information

XSLT and Structural Recursion. Gestão e Tratamento de Informação DEI IST 2011/2012

XSLT and Structural Recursion. Gestão e Tratamento de Informação DEI IST 2011/2012 XSLT and Structural Recursion Gestão e Tratamento de Informação DEI IST 2011/2012 Outline Structural Recursion The XSLT Language Structural Recursion : a different paradigm for processing data Data is

More information

JSON & MongoDB. Introduction to Databases CompSci 316 Fall 2018

JSON & MongoDB. Introduction to Databases CompSci 316 Fall 2018 JSON & MongoDB Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue. Oct. 30) Homework #3 due next Tuesday Project milestone #2 due next Thursday See email about new requirement on weekly

More information

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Part VII Querying XML The XQuery Data Model Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Outline of this part 1 Querying XML Documents Overview 2 The XQuery Data Model The XQuery

More information

XML and Semantic Web Technologies. II. XML / 6. XML Query Language (XQuery)

XML and Semantic Web Technologies. II. XML / 6. XML Query Language (XQuery) XML and Semantic Web Technologies XML and Semantic Web Technologies II. XML / 6. XML Query Language (XQuery) Prof. Dr. Dr. Lars Schmidt-Thieme Information Systems and Machine Learning Lab (ISMLL) Institute

More information

XQ: An XML Query Language Language Reference Manual

XQ: An XML Query Language Language Reference Manual XQ: An XML Query Language Language Reference Manual Kin Ng kn2006@columbia.edu 1. Introduction XQ is a query language for XML documents. This language enables programmers to express queries in a few simple

More information

XML-XQuery and Relational Mapping. Introduction to Databases CompSci 316 Spring 2017

XML-XQuery and Relational Mapping. Introduction to Databases CompSci 316 Spring 2017 XML-XQuery and Relational Mapping Introduction to Databases CompSci 316 Spring 2017 2 Announcements (Wed., Apr. 12) Homework #4 due Monday, April 24, 11:55 pm 4.1, 4.2, 4.3, X1 is posted Please start early

More information

The XQuery Data Model

The XQuery Data Model The XQuery Data Model 9. XQuery Data Model XQuery Type System Like for any other database query language, before we talk about the operators of the language, we have to specify exactly what it is that

More information

XML and Semi-structured Data

XML and Semi-structured Data XML and Semi-structured Data Krzysztof Trawiński Winter Semester 2008 slides 1/27 Outline 1. Introduction 2. Usage & Design 3. Expressions 3.1 Xpath 3.2 Datatypes 3.3 FLWOR 4. Functions 5. Summary 6. Questions

More information

Lecture 20 (Additional/Optional Slides) NoSQL/MongoDB

Lecture 20 (Additional/Optional Slides) NoSQL/MongoDB CompSci 516 Database Systems Lecture 20 (Additional/Optional Slides) NoSQL/MongoDB Instructor: Sudeepa Roy Duke CS, Fall 2018 CompSci 516: Database Systems 1 Additional and Optional Slides on MongoDB (May

More information

12. MS Access Tables, Relationships, and Queries

12. MS Access Tables, Relationships, and Queries 12. MS Access Tables, Relationships, and Queries 12.1 Creating Tables and Relationships Suppose we want to build a database to hold the information for computers (also refer to parts in the text) and suppliers

More information

XSLT program. XSLT elements. XSLT example. An XSLT program is an XML document containing

XSLT program. XSLT elements. XSLT example. An XSLT program is an XML document containing XSLT CPS 216 Advanced Database Systems Announcements (March 24) 2 Homework #3 will be assigned next Tuesday Reading assignment due next Wednesday XML processing in Lore (VLDB 1999) and Niagara (VLDB 2003)

More information

EMERGING TECHNOLOGIES

EMERGING TECHNOLOGIES EMERGING TECHNOLOGIES XML (Part 3): XQuery Outline 1. Introduction 2. Structure of XML data 3. XML Document Schema 3.1. Document Type Definition (DTD) 3.2. XMLSchema 4. Data Model for XML documents. 5.

More information

Query Engines for Web-Accessible XML Data

Query Engines for Web-Accessible XML Data Query Engines for Web-Accessible XML Data Leonidas Fegaras Ramez Elmasri University of Texas at Arlington Fegaras & Elmasri CSE @ UTA 1 I will present: Adding XML Support to an OODB an extension to ODMG

More information

XQBE (XQuery By Example): A Visual Interface to the Standard XML Query Language

XQBE (XQuery By Example): A Visual Interface to the Standard XML Query Language XQBE (XQuery By Example): A Visual Interface to the Standard XML Query Language DANIELE BRAGA, ALESSANDRO CAMPI, and STEFANO CERI Politecnico di Milano The spreading of XML data in many contexts of modern

More information

Additional Readings on XPath/XQuery Main source on XML, but hard to read:

Additional Readings on XPath/XQuery Main source on XML, but hard to read: Introduction to Database Systems CSE 444 Lecture 10 XML XML (4.6, 4.7) Syntax Semistructured data DTDs XML Outline April 21, 2008 1 2 Further Readings on XML Additional Readings on XPath/XQuery Main source

More information

The NEXT Framework for Logical XQuery Optimization

The NEXT Framework for Logical XQuery Optimization The NEXT Framework for Logical XQuery Optimization Alin Deutsch Yannis Papakonstantinou Yu Xu University of California, San Diego deutsch,yannis,yxu @cs.ucsd.edu Abstract Classical logical optimization

More information

XML-QE: A Query Engine for XML Data Soures

XML-QE: A Query Engine for XML Data Soures XML-QE: A Query Engine for XML Data Soures Bruce Jackson, Adiel Yoaz {brucej, adiel}@cs.wisc.edu 1 1. Introduction XML, short for extensible Markup Language, may soon be used extensively for exchanging

More information

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data Outline Conceptual Design: ER model Relational Algebra Calculus Yanlei Diao UMass Amherst Logical Design: ER to relational model Querying and manipulating data Practical language: SQL Declarative: say

More information

XML Stream Processing

XML Stream Processing XML Stream Processing Dan Suciu www.cs.washington.edu/homes/suciu Joint work with faculty, visitors and students at UW Introduction This is a research project at UW Partially supported by MS Two parts:

More information

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1 Slide 27-1 Chapter 27 XML: Extensible Markup Language Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree) Data Model. XML Documents, DTD, and XML Schema.

More information

AN EFFECTIVE APPROACH FOR MODIFYING XML DOCUMENTS IN THE CONTEXT OF MESSAGE BROKERING

AN EFFECTIVE APPROACH FOR MODIFYING XML DOCUMENTS IN THE CONTEXT OF MESSAGE BROKERING AN EFFECTIVE APPROACH FOR MODIFYING XML DOCUMENTS IN THE CONTEXT OF MESSAGE BROKERING R. Gururaj, Indian Institute of Technology Madras, gururaj@cs.iitm.ernet.in M. Giridhar Reddy, Indian Institute of

More information

Navigating Input Documents Using Paths4

Navigating Input Documents Using Paths4 Chapter 4 CHAPTER 4 Navigating Input Documents Using Paths4 Path expressions are used to navigate input documents to select elements and attributes of interest. This chapter explains how to use path expressions

More information

XSLT. Announcements (October 24) XSLT. CPS 116 Introduction to Database Systems. Homework #3 due next Tuesday Project milestone #2 due November 9

XSLT. Announcements (October 24) XSLT. CPS 116 Introduction to Database Systems. Homework #3 due next Tuesday Project milestone #2 due November 9 XSLT CPS 116 Introduction to Database Systems Announcements (October 24) 2 Homework #3 due next Tuesday Project milestone #2 due November 9 XSLT 3 XML-to-XML rule-based transformation language Used most

More information

XML, DTD, and XPath. Announcements. From HTML to XML (extensible Markup Language) CPS 116 Introduction to Database Systems. Midterm has been graded

XML, DTD, and XPath. Announcements. From HTML to XML (extensible Markup Language) CPS 116 Introduction to Database Systems. Midterm has been graded XML, DTD, and XPath CPS 116 Introduction to Database Systems Announcements 2 Midterm has been graded Graded exams available in my office Grades posted on Blackboard Sample solution and score distribution

More information

XML: Extensible Markup Language

XML: Extensible Markup Language XML: Extensible Markup Language CSC 375, Fall 2015 XML is a classic political compromise: it balances the needs of man and machine by being equally unreadable to both. Matthew Might Slides slightly modified

More information

Data Formats and APIs

Data Formats and APIs Data Formats and APIs Mike Carey mjcarey@ics.uci.edu 0 Announcements Keep watching the course wiki page (especially its attachments): https://grape.ics.uci.edu/wiki/asterix/wiki/stats170ab-2018 Ditto for

More information

XQuery Layers. Daniele Braga Alessandro Campi Stefano Ceri Paola Spoletini

XQuery Layers. Daniele Braga Alessandro Campi Stefano Ceri Paola Spoletini XQuery Layers Daniele Braga Alessandro Campi Stefano Ceri Paola Spoletini Politecnico di Milano - Dipartimento di Elettronica e Informazione Piazza Leonardo da Vinci 32, 20133 Milano, Italy { braga / campi

More information

Extending XQuery with Window Functions

Extending XQuery with Window Functions Extending XQuery with Window Functions Tim Kraska ETH Zurich September 25, 2007 Motivation XML is the data format for communication data (RSS, Atom, Web Services) meta data, logs (XMI, schemas, config

More information

XML. Document Type Definitions. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta

XML. Document Type Definitions. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta XML Document Type Definitions 1 XML XML stands for extensible Markup Language. XML was designed to describe data. XML has come into common use for the interchange of data over the Internet. 2 Well-Formed

More information

Overview: XQuery 3.0

Overview: XQuery 3.0 XQuery 3.0 Overview: XQuery 3.0 Fix shortcomings of XQuery 1.0, not a radical change Better align XPath 3.0, XSLT 3.0, XQuery 3.0 (thus the version!) Properly incorporate some of the best ideas from other

More information

Course: The XPath Language

Course: The XPath Language 1 / 27 Course: The XPath Language Pierre Genevès CNRS University of Grenoble, 2012 2013 2 / 27 Why XPath? Search, selection and extraction of information from XML documents are essential for any kind of

More information

(One) Layer Model of the Semantic Web. Semantic Web - XML XML. Extensible Markup Language. Prof. Dr. Steffen Staab Dipl.-Inf. Med.

(One) Layer Model of the Semantic Web. Semantic Web - XML XML. Extensible Markup Language. Prof. Dr. Steffen Staab Dipl.-Inf. Med. (One) Layer Model of the Semantic Web Semantic Web - XML Prof. Dr. Steffen Staab Dipl.-Inf. Med. Bernhard Tausch Steffen Staab - 1 Steffen Staab - 2 Slide 2 Extensible Markup Language Purpose here: storing

More information

Semistructured Data and XML

Semistructured Data and XML Semistructured Data and XML Computer Science E-66 Harvard University David G. Sullivan, Ph.D. Structured Data The logical models we've covered thus far all use some type of schema to define the structure

More information

A Modular modular XQuery implementation

A Modular modular XQuery implementation A Modular modular XQuery implementation Implementation Jan Vraný, Jan Jan Vraný, Jan Žák Žák Department of Computer Science and Engineering, FEE, Czech Technical University Department of Computer in Prague,

More information

Chapter 4. XML Query Languages. Foundations XML Path Language (XPath) 2.0 XQuery 1.0: An XML Query Language XIRQL

Chapter 4. XML Query Languages. Foundations XML Path Language (XPath) 2.0 XQuery 1.0: An XML Query Language XIRQL Chapter 4 XML Query Languages Foundations XML Path Language (XPath) 2.0 XQuery 1.0: An XML Query Language XIRQL History SQL OQL UnQL Lorel 1998 XSLT XQL XML-QL XML 1.0 DOM 1999 XPath 1.0 2000 Quilt 2001

More information

Chapter 8 XQuery. Recent Developments for Data Models

Chapter 8 XQuery. Recent Developments for Data Models Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 8 XQuery Recent Developments for Data Models Outline Overview

More information

XPath. by Klaus Lüthje Lauri Pitkänen

XPath. by Klaus Lüthje Lauri Pitkänen XPath by Klaus Lüthje Lauri Pitkänen Agenda Introduction History Syntax Additional example and demo Applications Xpath 2.0 Future Introduction Expression language for Addressing portions of an XML document

More information

Overview. Structured Data. The Structure of Data. Semi-Structured Data Introduction to XML Querying XML Documents. CMPUT 391: XML and Querying XML

Overview. Structured Data. The Structure of Data. Semi-Structured Data Introduction to XML Querying XML Documents. CMPUT 391: XML and Querying XML Database Management Systems Winter 2004 CMPUT 391: XML and Querying XML Lecture 12 Overview Semi-Structured Data Introduction to XML Querying XML Documents Dr. Osmar R. Zaïane University of Alberta Chapter

More information

Fall, 2004 CIS 550. Database and Information Systems Midterm Solutions

Fall, 2004 CIS 550. Database and Information Systems Midterm Solutions Fall, 2004 CIS 550 Database and Information Systems Midterm Solutions The exam is 80 minutes long. There are 100 points total, plus 10 points extra credit. Please look at both sides of the paper. The last

More information

CMPSCI 645 Database Design & Implementation

CMPSCI 645 Database Design & Implementation Welcome to CMPSCI 645 Database Design & Implementation Instructor: Gerome Miklau Overview of Databases Gerome Miklau CMPSCI 645 Database Design & Implementation UMass Amherst Jan 19, 2010 Some slide content

More information

BlossomTree: Evaluating XPaths in FLWOR Expressions

BlossomTree: Evaluating XPaths in FLWOR Expressions BlossomTree: Evaluating XPaths in FLWOR Expressions Ning Zhang University of Waterloo School of Computer Science nzhang@uwaterloo.ca Shishir K. Agrawal Indian Institute of Technology, Bombay Department

More information