Lecture 6: XML Query Languages Thursday, January 18, 2001.

Slides:



Advertisements
Similar presentations
Spring Part III: Introduction to XPath XML Path Language.
Advertisements

Internet Technologies1 1 Lecture 4: Programming with XSLT.
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XPath Laks V.S. Lakshmanan UBC CPSC 534B. Overview data model recap XPath examples some advanced features summary.
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.
1 Part 3: Query Languages Managing XML and Semistructured Data.
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
Agenda from now on Done: SQL, views, transactions, conceptual modeling, E/R, relational algebra. Starting: XML To do: the database engine: –Storage –Query.
Managing XML and Semistructured Data Lecture 8: Query Languages - XML-QL Prof. Dan Suciu Spring 2001.
Querying XML (cont.). Comments on XPath? What’s good about it? What can’t it do that you want it to do? How does it compare, say, to SQL?
1 Lecture 10 XML Wednesday, October 18, XML Outline XML (4.6, 4.7) –Syntax –Semistructured data –DTDs.
XSL Transformations Lecture 8, 07/08/02. Templates The whole element is a template The match pattern determines where this template applies Result element(s)
XPath By Laouina Marouane. Outline  Introduction  Data Model  Expression Patterns Patterns Location Paths Location Paths  Example  XPath 2.0  Practice.
1 Efficient Processing of XPath Queries Using Indexes Yan Chen 1, Sanjay Madria 1, Kalpdrum Passi 2, Sourav Bhowmick 3 1 Department of Computer Science,
XML May 2 nd, Agenda XML as a data model Querying XML Manipulating XML A lot of discussion, politics and stories.
Managing XML and Semistructured Data Lecture 6: XPath Prof. Dan Suciu Spring 2001.
XML May 1 st, XML for Representing Data John 3634 Sue 6343 Dick 6363 John 3634 Sue 6343 Dick 6363 row name phone “John”3634“Sue”“Dick” persons.
1 Introduction to Database Systems CSE 444 Lecture 11 Xpath/XQuery April 23, 2008.
1 Lecture 11: Xpath/XQuery Friday, October 20, 2006.
4/15/2002Bo Du 1 - Bo Du, April 15, XML - QL A Query Language for XML.
Lecture #6 XML November 2 nd, Administration Thanks for the mid-term comments Comment on the book & readings Project #2 Project #1 Homework #4 Homework.
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.
XPath Tao Wan March 04, What is XPath? n A language designed to be used by XSL Transformations (XSLT), Xlink, Xpointer and XML Query. n Primary.
Managing XML Data Dan Suciu University of Washington.
XML, XML Schema, XPath and XQuery Query Languages CS561 Slides collated from several sources, including D. Suciu at Univ. of Washington.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
1 Lecture 08: XML and Semistructured Data. 2 Outline XML (Section 17) –XML syntax, semistructured data –Document Type Definitions (DTDs) XPath.
Managing XML and Semistructured Data Lecture 2: XML Prof. Dan Suciu Spring 2001.
1 Lecture 08: XML and Semistructured Data. 2 Outline XML (Section 17) –XML syntax, semistructured data –Document Type Definitions (DTDs) XPath.
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:
1 Lecture 16: Querying XML Data: XPath, XQuery Friday, February 11, 2005.
Querying XML February 12 th, Querying XML Data XPath = simple navigation through the tree XQuery = the SQL of XML XSLT = recursive traversal –will.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
Web Data Management XPath.
Dan SuciuTools for XML Data Exchange Dan Suciu AT&T Labs Joint work with Mary Fernandez.
XML and XPath. Web Services: XML+XPath2 EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML origins: structured.
Semistructured data and XML CS 645 April 5, 2006 Some slide content courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
Session II Chapter 2 – Chapter 2 – XSLhttp://
Management of XML and Semistructured Data Lecture 5: Query Languages Wednesday, 4/1/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.
CSE 636 Data Integration Fall 2006 XML Query Languages XPath.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
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.
1 Introduction to Semistructured Data and XML. 2 How the Web is Today  HTML documents often generated by applications consumed by humans only easy access:
More XML: semantics, DTDs, XPATH February 18, 2004.
1 XQuery Slides From Dr. Suciu. 2 XQuery Based on Quilt, which is based on XML-QL Uses XPath to express more complex queries.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
IS432 Semi-Structured Data Lecture 4: XPath Dr. Gamal Al-Shorbagy.
Semi-structured Data In many applications, data does not have a rigidly and predefined schema: –e.g., structured files, scientific data, XML. Managing.
1 Lecture 5: Relational Algebra and XML Monday, April 26th, 2004.
Lecture 17: XPath and XQuery Wednesday, Nov. 7, 2001.
1 Lecture 12: XML, XPath, XQuery Friday, October 24, 2003.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
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 path expressions CSE 350 Fall 2003.
Lecture 11: Xpath/XQuery
Management of XML and Semistructured Data
XML: Schemas, Queries Wednesday, 4/17/2002
Lecture 12: XML, XPath, XQuery
Lecture 9: XML Monday, October 17, 2005.
More XML XML schema, XPATH, XSLT
Lecture 15: Querying XML Friday, October 27, 2000.
Lecture 11: XML and Semistructured Data
Presentation transcript:

Lecture 6: XML Query Languages Thursday, January 18, 2001

Outline XPath XML-QL XSL (XSLT)

An Example of XML Data Addison-Wesley Serge Abiteboul Rick Hull Victor Vianu Foundations of Databases 1995 Freeman Jeffrey D. Ullman Principles of Database and Knowledge Base Systems 1998

XPath Syntax for XML document navigation and node selection A recommendation of the W3C (i.e. a standard) Building block for other W3C standards: – XSL Transformations (XSLT) – XML Link (XLink) – XML Pointer (XPointer) Was originally part of XSL – “XSL pattern language”

XPath: Simple Expressions /bib/book/year Result: /bib/paper/year Result: empty (there were no papers)

XPath: Restricted Kleene Closure //author Result: Serge Abiteboul Rick Hull Victor Vianu Jeffrey D. Ullman /bib//first-name Result: Rick

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

Xpath: Wildcard //author/* Result: Rick Hull * Matches any element

Xpath: Attribute Nodes Result: means that price is has to be an attribute

Xpath: Qualifiers /bib/book/author[firstname] Result: Rick Hull

Xpath: More Qualifiers /bib/book/author[firstname][address[//zip][city]]/lastname Result: … …

Xpath: More Qualifiers < “60”] < “25”] /bib/book[author/text()]

Xpath: Summary bibmatches a bib element *matches any element /matches the root element /bibmatches a bib element under root bib/papermatches a paper in bib bib//papermatches a paper in bib, at any depth //papermatches a paper at any depth paper|bookmatches a paper or a a price attribute price attribute in book, in bib matches…

Xpath: More Details An Xpath expression, p, establishes a relation between: –A context node, and –A node in the answer set In other words, p denotes a function: –S[p] : Nodes -> {Nodes} Examples: –author/firstname –. = self –.. = parent –part/*/*/subpart/../name = what does it mean ?

The Root and the Root 1 2 bib is the “document element” The “root” is above bib /bib = returns the document element / = returns the root Why ? Because we may have comments before and after ; they become siblings of This is advanced xmlogy

Xpath: More Details We can navigate along 13 axes: ancestor ancestor-or-self attribute child descendant descendant-or-self following following-sibling namespace parent preceding preceding-sibling self

Xpath: More Details Examples: –child::author/child:lastname = author/lastname –child::author/descendant::zip = author//zip –child::author/parent::* = author/.. –child::author/attribute::age =

XML-QL: A Query Language for XML (8/98) features: –regular path expressions –patterns, templates –subqueries –Skolem Functions based on a graph model (the OEM data model) –sometimes things don’t work smoothly with XML

Pattern Matching in XML-QL where Morgan Kaufmann $a in “ construct $a where Morgan Kaufmann $a in “ construct $a … is called a pattern Pattern = like XML fragment, but may have variables

Abbreviations in XML-QL where Morgan Kaufmann $a in “ construct $a where Morgan Kaufmann $a in “ construct $a abbreviated with

Simple Constructors in XML-QL where $a in “ construct $a $l where $a in “ construct $a $l … is called a template Answer is: Smith English Smith Mandarin Doe English

Regular Expressions in XML-QL Uses traditional syntax for regular expressions where spring $m $p in “ construct $m $p where spring $m $p in “ construct $m $p

Regular Expressions in XML-QL Can use the following: R ::= tag | _ | R.R | R|R | R* | R+ | R? Notice: XPath corresponds to: R ::= tag | _ | R.R | R|R | _*

Nested Queries in XML-QL where $a in “ construct $a where $a $t in “ construct $t where $a in “ construct $a where $a $t in “ construct $t

Nested Queries in XML-QL Results will be grouped by authors: John t1 t2 … Smith … What happens to duplicate authors ? Need Skolem functions…

Representing References in XML Jane Mary John oids and references in XML are just syntax

Note: References in XML vs Semistructured Data Alan 42 { person: &o123 { name: “Alan”, age: 42, } } person nameage person name age father … { person: { father: &o123 …} } similar on trees, different on graphs

Skolem Functions in XML-QL where $a $t in “ construct $a $t where $a $t in “ construct $a $t What happens to duplicate authors ?

More on Skolem Functions where $a $t in “ construct $a $t where $a $t in “ construct $a $t what does it do ? what about the order ?

More on Skolem Functions where $a $t in “ construct $a $t where $a $t in “ construct $a $t what happens here ? need discipline in using Skolem functions, otherwise we get a graph

XSL = XSLT + XPath A recommendation of the W3C (standard) Initial goal: translate XML to HTML Became: translate XML to XML –HTML is just a particular case of XML

XSL Templates and Rules query = collection of template rules template rule = match pattern + template Retrieve all book titles:

XSL for Stylesheets Authors in italic, title in boldface All books in our database, All books in our database,

Input XML Addison-Wesley Serge Abiteboul Rick Hull Victor Vianu Foundations of Databases 1995 Freeman Jeffrey D. Ullman Principles of Database and Knowledge Base Systems 1998

Output HTML All books in our database Serge Abiteboul, Rick Hull, Victor Vianu, Foundations of Databases Jeffrey D. Ullman, Principles of Database and Knowledge Base Systems

Flow Control in XSL

XSLT

XSLT What is the output on: ?

Answer: