Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.

Slides:



Advertisements
Similar presentations
W3C SML F2F XML Schema 1.1 Sandy Gao, IBM.
Advertisements

XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
XML Examples. Bank Information Basic structure: A-101 Downtown 500 … Johnson Alma Surrey … A-101 Johnson …
XML: Extensible Markup Language
1 Chapter 30 Semistructured Data and XML Transparencies © Pearson Education Limited 1995, 2005.
Bottom-up Evaluation of XPath Queries Stephanie H. Li Zhiping Zou.
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?
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.
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.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
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.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 XQuery Values FLWR Expressions Other Expressions.
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.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
4/20/2017.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Navigating XML. Overview  Xpath is a non-xml syntax to be used with XSLT and Xpointer. Its purpose according to the W3.org is  to address parts of an.
Lecture 21 XML querying. 2 XSL (eXtensible Stylesheet Language) In HTML, default styling is built into browsers as tag set for HTML is predefined and.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
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.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
CSC271 Database Systems Lecture # 12. Summary: Previous Lecture  Row selection using WHERE clause  WHERE clause and search conditions  Sorting results.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XQL, OQL and SQL Xia Tang Sixin Qian Shijun Shen Feb 18, 2000.
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.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
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.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
XML – Part III. The Element … This type of element either has the element content or the mixed content (child element and data) The attributes of the.
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
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.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
Tutorial 13 Validating Documents with Schemas
1 XML Data Management XPath Principles Werner Nutt.
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://
Friday, September 4 th, 2009 The Systems Group at ETH Zurich XML and Databases Exercise Session 5 courtesy of Ghislain Fourny/ETH © Department of Computer.
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 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
IST 210 More SQL Todd Bacastow IST 210: Organization of Data.
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Schema – XSLT Week 8 Web site:
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Query Languages for XML
XML: Extensible Markup Language
Unit 4 Representing Web Data: XML
Querying and Transforming XML Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Chapter 7 Representing Web Data: XML
XQuery Leonidas Fegaras.
Presentation transcript:

Lecture 22 XML querying

2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison operators (‘eq’, ‘ne’, ‘lt’, ‘le’, ‘gt’, ‘ge’), which are used to compare two atomic values. If either operand is a node, atomization is used to convert it to an atomic value. If we try to compare an atomic value to an expression that returns multiple nodes, then a general comparison operator returns true if any value satisfies predicate; however, value comparison operator would raise an error.

3 Example 31.5 – XQuery FLWOR Expressions List staff at branch B005 with salary > £15,000. FOR $S IN doc(“staff_list.xml”)//STAFF WHERE $S/SALARY > AND = “B005” RETURN $S/STAFFNO Effective boolean value (EBV) of empty sequence is false; EBV also false if expression evaluates to: xsd:boolean value false, a numeric or binary zero, a zero-length string, or special float value NaN (not a number); EBV of any other sequence evaluates to true.

4 Example 31.5 – XQuery FLWOR Expressions List all staff in descending order of staff number. FOR $S IN doc(“staff_list.xml”)//STAFF ORDER BY $S/STAFFNO DESCENDING” RETURN $S/STAFFNO

5 Example 31.5 – XQuery FLWOR Expressions List each branch office and average salary at branch. FOR $B IN LET $avgSalary := avg(doc(“staff_list.xml”)// = $B]/SALARY) RETURN { $B/text() }, $avgSalary

6 Example 31.5 – XQuery FLWOR Expressions List branches that have more than 20 staff. FOR $B IN LET $S := = $B] WHERE count($S) > 20 RETURN { $B/text() }

7 Example 31.5 – XQuery FLWOR Expressions List branches with at least one member of staff with salary > £15,000. FOR $B IN LET $S := = $B] WHERE SOME $sal IN $S/SALARY SATISFIES ($sal > 15000) RETURN { $B/text() }

8 Example 31.6 – Joining Two Documents List staff along with details of their next of kin. FOR $S IN doc(“staff_list.xml”)//STAFF, $NOK IN doc(“nok.xml”)//NOK WHERE $S/STAFFNO = $NOK/STAFFNO RETURN { $S, $NOK/NAME }

9 Example 31.6 – Joining Two Documents List all staff along with details of their next of kin. FOR $S IN doc(“staff_list.xml”)//STAFF RETURN { $S } FOR $NOK IN doc(“nok.xml”)//NOK WHERE $S/STAFFNO = $NOK/STAFFNO RETURN $NOK/NAME

10 Example 31.6 – Joining Two Documents List each branch office and staff who work there. FOR $B IN ORDER BY $B RETURN { $B/text() } { FOR $S IN doc(“staff_list.xml”)//STAFF WHERE = $B ORDER BY $S/STAFFNO RETURN $S/STAFFNO, $S/NAME, $S/POSITION, $S/SALARY }

11 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo) AS element()* { FOR $S IN doc(“staff_list.xml”)//STAFF WHERE = $bNo ORDER BY $S/STAFFNO RETURN $S/STAFFNO, $S/NAME, $S/POSITION, $S/SALARY } staffAtBranch($B)

12 XML Information Set (Infoset) Abstract description of information available in well-formed XML document that meets certain XML namespace constraints. XML Infoset is attempt to define set of terms that other XML specifications can use to refer to the information items in a well- formed (although not necessarily valid) XML document. Does not attempt to define complete set of information, nor does it represent minimal information that an XML processor should return to an application. It also does not mandate a specific interface or class of interfaces (although Infoset presents information as tree).

13 XML Information Set (Infoset) XML document’s information set consists of two or more information items. An information item is an abstract representation of a component of an XML document such as an element, attribute, or processing instruction. Each information item has a set of associated properties. e.g., document information item properties include: [document element]; [children]; [notations]; [unparsed entities]; [base URI], [character encoding scheme], [version], and [standalone].

14 Post-Schema Validation Infoset (PSVI) XML Infoset contains no type information. To overcome this, XML Schema specifies an extended form of XML Infoset called Post-Schema Validation Infoset (PSVI). In PSVI, information items representing elements and attributes have type annotations and normalized values that are returned by an XML Schema processor. PSVI contains all information about an XML document that a query processor requires.

15 XQuery 1.0 and XPath 2.0 Data Model Defines the information contained in the input to an XSLT or XQuery Processor. Also defines all permissable values of expressions in XSLT, XQuery, and XPath. Data Model is based on XML Infoset, with following new features: support for XML Schema types; representation of collections of documents and of simple and complex values.

16 XQuery 1.0 and XPath 2.0 Data Model Decided to make XPath subset of XQuery. XPath spec shows how to represent information in XML Infoset as a tree structure containing seven kinds of nodes (document, element, attribute, text, comment, namespace, or processing instruction), with XPath operators defined in terms of these seven nodes. To retain these operators while using richer type system provided by XML Schema, XQuery extended XPath data model with additional information contained in PSVI.

17 XQuery 1.0 and XPath 2.0 Data Model Data Model is node-labeled, tree-constructor, with notion of node identity to simplify representation of reference values (such as IDREF, XPointer, and URI values). An instance of data model represents one or more complete documents or document parts, each represented by its own tree of nodes. Every value is ordered sequence of zero or more items, where an item can be an atomic value or a node. An atomic value has a type, either one of atomic types defined in XML Schema or restriction of one of these types. When a node is added to a sequence its identity remains same. Thus, a node may occur in more than one sequence and a sequence may contain duplicate items.

18 XQuery 1.0 and XPath 2.0 Data Model Root node representing XML document is a document node and each element in document is represented by an element node. Attributes represented by attribute nodes and content by text nodes and nested element nodes. Primitive data in document is represented by text nodes, forming the leaves of the node tree. Element node may be connected to attribute nodes and text nodes/nested element nodes. Every node belongs to exactly one tree, and every tree has exactly one root node. Tree whose root node is document node is referred to as a document and a tree whose root node is some other kind of node is referred to as a fragment.

19 XQuery 1.0 and XPath 2.0 Data Model Information about nodes obtained via accessor functions that can operate on any node. Accessor functions are analogous to an information item’s named properties. These functions are illustrative and intended to serve as concise description of information that must be exposed by Data Model. Data Model also specifies a number of constructor functions whose purpose is to illustrate how nodes are constructed.

20 ER Diagram Representing Main Components

21 Example XML Query Data Model

22 Example XML Query Data Model

23 Example XML Query Data Model

24 Example XML Query Data Model

25 Example XML Query Data Model

26 Example XML Query Data Model