1 XML Query Languages XPATH XQUERY. 2 XPATH and XQUERY uXPATH is a language for describing paths in XML documents. wReally think of the semistructured.

Slides:



Advertisements
Similar presentations
2/10/05Salman Azhar: Database Systems1 XML Query Languages Salman Azhar XPATH XQUERY These slides use some figures, definitions, and explanations from.
Advertisements

XML Examples. Bank Information Basic structure: A-101 Downtown 500 … Johnson Alma Surrey … A-101 Johnson …
XML: Extensible Markup Language
Covering Indexes for XML Queries by Prakash Ramanan
SQL Group Members: Shijun Shen Xia Tang Sixin Qiang.
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
From Semistructured Data to XML: Migrating The Lore Data Model and Query Language Roy Goldman, Jason McHugh, Jennifer Widom Stanford University
1 XPath Path Expressions Conditions. 2 Paths in XML Documents uXPath is a language for describing paths in XML documents. uReally think of the semistructured.
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.
Winter 2002Arthur Keller – CS 18018–1 Schedule Today: Mar. 12 (T) u Semistructured Data, XML, XQuery. u Read Sections Assignment 8 due. Mar. 14.
Managing XML and Semistructured Data Lecture 6: XPath Prof. Dan Suciu Spring 2001.
1 XML Document Type Definitions XML Schema. 2 Well-Formed and Valid XML uWell-Formed XML allows you to invent your own tags. uValid XML conforms to a.
Fall 2001Arthur Keller – CS 18017–1 Schedule Nov. 27 (T) Semistructured Data, XML. u Read Sections Assignment 8 due. Nov. 29 (TH) The Real World,
Lecture 12. Default Processing in XSLT The default processing in XSLT is to process the XPath root node The default processing for various node types.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
XML, XML Schema, XPath and XQuery Query Languages CS561 Slides collated from several sources, including D. Suciu at Univ. of Washington.
1 XQuery Values FLWR Expressions Other Expressions.
1 Query Languages for XML XPath XQuery XSLT. 2 The XPath/XQuery Data Model uCorresponding to the fundamental “relation” of the relational model is: sequence.
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
SD2520 Databases using XML and JQuery
XML Document Type Definitions XML Schema. Motivation for Semistructured data Serves as a model suitable for integration of databases Notations such as.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
XML Semi-structured data XML Document Type Definitions (DTD)
1 Lecture 5: XML and XQuery. 2 Semistructured Data uAnother data model, based on trees. uMotivation: flexible representation of data. wOften, data comes.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
CSCE 520- Relational Data Model Lecture 2. Relational Data Model The following slides are reused by the permission of the author, J. Ullman, from the.
Document Type Definitions XML Schema
Advance Database S Week-7 Dr.Kwanchai Eurviriyanukul
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
Winter 2006Keller, Ullman, Cushing18–1 Plan 1.Information integration: important new application that motivates what follows. 2.Semistructured data: a.
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
1 XQuery uXQuery extends XPath to a query language that has power similar to SQL. uUses the same sequence-of-items data model. uXQuery is an expression.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
Lecture 6: XML Query Languages Thursday, January 18, 2001.
Database Systems Part VII: XML Querying Software School of Hunan University
XPath Aug ’10 – Dec ‘10. XPath   XML Path Language   Technology that allows to select a part or parts of an XML document to process   XPath was.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
Jeff Ullman: Introduction to XML 1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
Semistructured Data Extensible Markup Language Document Type Definitions Zaki Malik November 04, 2008.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
1 XML Data Management Extracting Data from XML: XPath Werner Nutt based on slides by Sara Cohen, Jerusalem.
Exam II Syllabus uStorage & Buffer Management uIndexing: Btrees & Hash uMulti-dimensional Indexing uQuery processing (relational ops) uQuery optimization.
1 XML Data Management XPath Principles Werner Nutt.
CSCE 520- Relational Data Model Lecture 2. Oracle login Login from the linux lab or ssh to one of the linux servers using your cse username and password.
XML Query Languages XPATH XQUERY Zaki Malik November 11, 2008.
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.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
XML Query languages--XPath. Objectives Understand XPath, and be able to use XPath expressions to find fragments of an XML document Understand tree patterns,
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Query Languages for XML
XML: Extensible Markup Language
Querying and Transforming XML Data
XML Base de Datos September 4, 2018September 4, 2018September 4, 2018September 4, 2018.
CS 480: Database Systems Lecture 28 March 22, 2013.
XML Path Language Andy Clark 17 Apr 2002.
XML Data DTDs, IDs & IDREFs.
XQuery Leonidas Fegaras.
Query Languages for XML
Presentation transcript:

1 XML Query Languages XPATH XQUERY

2 XPATH and XQUERY uXPATH is a language for describing paths in XML documents. wReally think of the semistructured data graph and its paths. uXQUERY is a full query language for XML documents with power similar to OQL.

3 Example DTD <!DOCTYPE Bars [ ]>

4 Example Document … <BEER name = “Bud”, soldBy = “JoesBar, SuesBar,…”> …

5 Path Descriptors uSimple path descriptors are sequences of tags separated by slashes (/). uIf the descriptor begins with /, then the path starts at the root and has those tags, in order. uIf the descriptor begins with //, then the path can start anywhere.

6 Example: /BARS/BAR/PRICE … <BEER name = “Bud”, soldBy = “JoesBar, SuesBar,…”> … /BARS/BAR/PRICE describes the set with these two PRICE objects as well as the PRICE objects for any other bars.

7 Example: //PRICE … <BEER name = “Bud”, soldBy = “JoesBar, SuesBar,…”> … //PRICE describes the same PRICE objects, but only because the DTD forces every PRICE to appear within a BARS and a BAR.

8 Wild-Card * uA star (*) in place of a tag represents any one tag. uExample: /*/*/PRICE represents all price objects at the third level of nesting.

9 Example: /BARS/* … <BEER name = “Bud”, soldBy = “JoesBar, SuesBar,…”> … /BARS/* captures all BAR and BEER objects, such as these.

10 Attributes uIn XPATH, we refer to attributes by to their name. uAttributes of a tag may appear in paths as if they were nested within that tag.

11 Example: … <BEER name = “Bud”, soldBy = “JoesBar, SuesBar,…”> … selects all name attributes of immediate subobjects of the BARS object.

12 Selection Conditions uA condition inside […] may follow a tag. uIf so, then only paths that have that tag and also satisfy the condition are included in the result of a path expression.

13 Example: Selection Condition u/BARS/BAR/PRICE[PRICE < 2.75] … The condition that the PRICE be < $2.75 makes this price but not the Miller price satisfy the path descriptor.

14 Example: Attribute in Selection = “Miller”] … Now, this PRICE object is selected, along with any other prices for Miller.

15 Axes uIn general, path expressions allow us to start at the root and execute a sequence of steps to find a set of nodes at each step. uAt each step, we may follow any one of several axes. uThe default axis is child:: --- go to any child of the current set of nodes.

16 Example: Axes u/BARS/BEER is really shorthand for /BARS/child::BEER. is really shorthand for the attribute:: axis. wThus, = “Bud” ] is shorthand for /BARS/BEER[attribute::name = “Bud”]

17 More Axes uSome other useful axes are: 1.parent:: = parent(s) of the current node(s). 2.descendant-or-self:: = the current node(s) and all descendants. wNote: // is really a shorthand for this axis. 3.ancestor::, ancestor-or-self, etc.

18 XQUERY uXQUERY allows us to query XML documents, using path expressions from XPATH to describe important sets. uCorresponding to SQL’s select-from- where is the XQUERY FLWR expression, standing for “for-let-where-return.”

19 FLWR Expressions 1.One or more FOR and/or LET clauses. 2.Then an optional WHERE clause. 3.A RETURN clause.

20 FOR Clauses FOR IN,… uVariables begin with $. uA FOR variable takes on each object in the set denoted by the path expression, in turn. uWhatever follows this FOR is executed once for each value of the variable.

21 Example: FOR FOR $beer IN RETURN $beer u$beer ranges over the name attributes of all beers in our example document. uResult is a list of tagged names, like Bud Miller …

22 LET Clauses LET :=,… uValue of the variable becomes the set of objects defined by the path expression. uNote LET does not cause iteration; FOR does.

23 Example: LET LET $beers := RETURN $beers uReturns one object with all the names of the beers, like: Bud, Miller,…

24 Following IDREF’s uXQUERY (but not XPATH) allows us to use paths that follow attributes that are IDREF’s. uIf x denotes a set of IDREF’s, then x =>y denotes all the objects with tag y whose ID’s are one of these IDREF’s.

25 Example uFind all the beer objects where the beer is sold by Joe’s Bar for less than uStrategy: 1.$beer will for-loop over all beer objects. 2.For each $beer, let $joe be either the Joe’s- Bar object, if Joe sells the beer, or the empty set of bar objects. 3.Test whether $joe sells the beer for < 3.00.

26 Example: The Query FOR $beer IN /BARS/BEER LET $joe := LET $joePrice := WHERE $joePrice < 3.00 RETURN $beer Attribute soldBy is of type IDREFS. Follow each ref to a BAR and check if its name is Joe’s Bar. Find that PRICE subobject of the Joe’s Bar object that represents whatever beer is currently $beer. Only pass the values of $beer, $joe, $joePrice to the RETURN clause if the string inside the PRICE object $joePrice is < 3.00