Management of XML and Semistructured Data Lecture 5: Query Languages Wednesday, 4/1/2001.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Spring Part III: Introduction to XPath XML Path Language.
Web Data Management XQuery 1. In this lecture Summary of XQuery FLWOR expressions – For, Let, Where, Order by, Return FOR and LET expressions Collections.
1 Web Data Management Path Expressions. 2 In this lecture Path expressions Regular path expressions Evaluation techniques Resources: Data on the Web Abiteboul,
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.
Agenda from now on Done: SQL, views, transactions, conceptual modeling, E/R, relational algebra. Starting: XML To do: the database engine: –Storage –Query.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
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?
QSX (LN 3)1 Query Languages for XML XPath XQuery XSLT (not being covered today!) (Slides courtesy Wenfei Fan, Univ Edinburgh and Bell Labs)
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)
1 COS 425: Database and Information Management Systems XML and information exchange.
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.
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.
XML, XML Schema, XPath and XQuery Query Languages CS561 Slides collated from several sources, including D. Suciu at Univ. of Washington.
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.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
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.
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.
CSE 636 Data Integration Fall 2006 XML Query Languages XPath.
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
More XML: semantics, DTDs, XPATH February 18, 2004.
1 XML Data Management Extracting Data from XML: XPath Werner Nutt based on slides by Sara Cohen, Jerusalem.
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.
Martin Kruliš by Martin Kruliš (v1.1)1.
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.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
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
XML in Web Technologies
XML: Schemas, Queries Wednesday, 4/17/2002
Lecture 12: XML, XPath, XQuery
Lecture 9: XML Monday, October 17, 2005.
Semi-structured Data In many applications, data does not have a rigidly and predefined schema: e.g., structured files, scientific data, XML. Managing such.
Lecture 15: Querying XML Friday, October 27, 2000.
Lecture 11: XML and Semistructured Data
Presentation transcript:

Management of XML and Semistructured Data Lecture 5: Query Languages Wednesday, 4/1/2001

Strudel and StruQL Strudel = a Website management tool Idea: separate the following three tasks –Management of data use some database –Management of the site’s structure use StruQL –Management of the site’s presentation use HTML templates (this was before XML...)

Example: Bibliography Data {Bib: { paper: { author: “Jones”, author: “Smith”, title: “The Comma”, year: 1994 }, paper: { author: “Jones”, title: “The Dot”, year: 1998 }, paper: { author: “Mark”,.... }... } {Bib: { paper: { author: “Jones”, author: “Smith”, title: “The Comma”, year: 1994 }, paper: { author: “Jones”, title: “The Dot”, year: 1998 }, paper: { author: “Mark”,.... }... } Input data: Bib paper author title year “Jones”“Smith”“The Comma”.....

Simple Website Definition in StruQL WHERE Root -> “Bib.paper.author” -> A CREATE Root(), HomePage(A) LINK Root() -> “person” -> HomePage(A), HomePage(A) -> “name” -> A HomePage(A) -> “home” -> Root() WHERE Root -> “Bib.paper.author” -> A CREATE Root(), HomePage(A) LINK Root() -> “person” -> HomePage(A), HomePage(A) -> “name” -> A HomePage(A) -> “home” -> Root() Root() HomePage(“Smith”)HomePage(“Jones”)HomePage(“Mark”) person StruQL query: Result: Root(), HomePage(A) = Skolem Functions (more later) “Smith”“Jones”“Mark” name home

Complex Website Definition in StruQL WHERE Root -> “Bib” -> X, X -> “paper” -> P, P -> “author” -> A, P -> “title” -> T, P -> “year” -> Y CREATE Root(), HomePage(A), YearPage(A,Y), PubPage(P) LINK Root() -> “person” -> HomePage(A), HomePage(A) -> “yearentry” -> YearPage(A,Y), YearPage(A,Y) -> “publication” -> PubPage(P), PubPage(P) -> “author” -> HomePage(A), PubPage(P) -> “title” -> T WHERE Root -> “Bib” -> X, X -> “paper” -> P, P -> “author” -> A, P -> “title” -> T, P -> “year” -> Y CREATE Root(), HomePage(A), YearPage(A,Y), PubPage(P) LINK Root() -> “person” -> HomePage(A), HomePage(A) -> “yearentry” -> YearPage(A,Y), YearPage(A,Y) -> “publication” -> PubPage(P), PubPage(P) -> “author” -> HomePage(A), PubPage(P) -> “title” -> T

Example: A Complex Web Site Root() YearPage(“Smith”, 1994) YearPage(“Smith”, 1996) YearPage(“Jones”, 1994) YearPage(“Jones”, 1998) YearPage(“Mark”, 1996) yearentry publication PubPage(“The Comma”)PubPage(“The Dot”) publication title author HomePage(“Smith”)HomePage(“Jones”)HomePage(“Mark”) person “The Comma”“The Dot”

Skolem Functions Maier, 1986 –in OO systems Kifer et al, 1989 –F-logic Hull and Yoshikawa, 1990 –deductive db (ILOG) Papakonstantinou et al., 1996 –semistructured db (MSL)

Skolem Functions in Logic Origins: First Order Logic The Satisfiability problem given a formula , does it have a model ?

Skolem Functions in Logic Example: does  have a model ? Skolem functions: replace  with functions, drop  Fact:  has a model iff  ’ “has a model”

Skolem Functions in Databases Recall Datalog: Means: Answer(title, author) :- Paper(author, title, year)

Skolem Functions in Databases Now consider: I want to “create a new object x”. What meaning ? Answer(author, x) :- Paper(author, title, year)

Skolem Functions in Databases Better: use Skolem functions directly in Datalog Choices: Answer(author, NewObj(author)) :- Paper(author, title, year) Answer(author, NewObj(author,title)) :- Paper(author, title, year) Answer(author, NewObj(title,year)) :- Paper(author, title, year) Answer(author, NewObj()) :- Paper(author, title, year)

Skolem Functions in StruQL StruQL’s semantics: Input graph: (Node, Edge) Output graph:(Node’, Edge’) Example: WHERE Root -> “Bib.paper.author” -> A CREATE Root(), HomePage(A) LINK Root() -> “person” -> HomePage(A), HomePage(A) -> “name” -> A HomePage(A) -> “home” -> Root() WHERE Root -> “Bib.paper.author” -> A CREATE Root(), HomePage(A) LINK Root() -> “person” -> HomePage(A), HomePage(A) -> “name” -> A HomePage(A) -> “home” -> Root() Node’(Root()) :- Node’(HomePage(A)) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Edge’(Root,person,HomePage(A)) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Edge’(HomePage(A),person, A) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Edge’(HomePage(A),home,Root()) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Node’(Root()) :- Node’(HomePage(A)) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Edge’(Root,person,HomePage(A)) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Edge’(HomePage(A),person, A) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A) Edge’(HomePage(A),home,Root()) :- Edge(Root,Bib,X), Edge(X,paper,Y),Edge(Y,author,A)

XPath (11/99) Building block for other W3C standards: – XSL Transformations (XSLT) – XML Link (XLink) – XML Pointer (XPointer) – XML Query Was originally part of XSL

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

Data Model for XPath bib book publisherauthor.. Addison-WesleySerge Abiteboul The root The root element Much like the Xquery data model

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 Functions in XPath: –text() = matches the text value –node() = matches any node (= * or text()) –name() = returns the name of the current tag

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 = part/*/*[subpart]/name

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 = What does this mean ? –paper/publisher/parent::*/author –/bib//address[ancestor::book] –/bib//author/ancestor::*//zip

Xpath: Even More Details name() = the name of the current node –/bib//*[name()=book] same as /bib//book What does this mean ? /bib//*[ancestor::*[name()!=book]] –In a different notation bib.[^book]*._ Navigation axis give us strictly more power !