XQuery - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

XQuery

Description:

XQuery – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 42
Provided by: one124
Category:
Tags: xquery

less

Transcript and Presenter's Notes

Title: XQuery


1
XQuery
Source http//www.srdc.metu.edu.tr/webpage/cours
es/ceng520
2
What is XQuery?
A language for querying XML A human-readable
syntax for an XML query language A functional
programming language The product of the W3Cs
XML Query Working Group
3
History
4
Resources
5
XQuery 1.0 XPath 2.0
XQueryX 1.0
XQuery 1.0
XPath 2.0
XQuery 1.0 Xpath 2.0Formal Semantics
XQuery 1.0 Xpath 2.0Functions Operators
XQuery 1.0 Xpath 2.0Data Model
XQuery 1.0 Xpath 2.0Requirements Use Cases
XML Schema 1.0
XML 1.0
Namespaces 1.0
6
Does the world need a new query language?
7
Nesting
8
Metadata
9
Ordering
10
Missing Information
11
General XQuery Rules
12
XQuery Expressions
13
Functions
14
Path Expressions
15
Predicates
16
Expressions
17
Logical Expressions
18
Constructors
19
FLWOR Expressions
20
An Example Query
21
Ways of qualifying a node ("Kind tests")
22
Testing Types
23
Structure of an XQuery
24
Namespace Declarations
25
Schema Imports
26
Function Definitions
27
Modules
28
Modules (continued)
29
Two Phases in Query Processing
30
Summary and Prognosis
31
Some Examples(1)
FOR - LET - WHERE - RETURN Similar to SQLs
SELECT - FROM - WHERE for book in
document("http//www.bn.com/bib.xml")//book
where book/publisher "Addison-Wesley" return
ltbookgt book/title,
book/author lt/bookgt
32
Some Examples(2)
_at_ indicates, attribute for bk in
document("http//www.bn.com/bib.xml")/bib/book
where bk/_at_year lt "1997 return bk/title
33
Some Examples(3)
Nested fors can be used, for a in
document("http//www.bn.com/bib.xml") for b
in a/bib for c in b/book
return ltauthorlistgt c/author lt/authorlistgt
34
Some Examples(4)
More than one bindings b, t, a ltresultsgt
for b in document("http//www.bn.com/bib.xml")/bi
b/book, t in b/title, a in b/author
return ltresultgt t a
lt/resultgt lt/resultsgt
35
Some Examples(5)
Join operation between two XML files ltbooks-with-
pricesgt for b in document("http//www.bn.com
/bib.xml")//book, a in document("http//www
.amazon.com/reviews.xml")//entry where
b/title a/title return
ltbook-with-pricesgt b/title
ltprice-amazongt a/price/text() lt/price-amazongt
ltprice-bngt b/price/text() lt/price-bngt
lt/book-with-pricesgt lt/books-with-pricesgt
36
Some Examples(6)
SORTBY can be used, ltbibliographygt FOR
book IN document("bib.xml")//book RETURN
ltbookgt book/author,
book/title lt/bookgt SORTBY
(author, title) lt/bibliographygt
37
Some Examples(7)
A function example FUNCTION depth(ELEMENT e)
RETURNS integer -- An empty element has
depth 1 -- Otherwise, add 1 to max depth of
children IF empty(e/) THEN 1
ELSE max(depth(e/)) 1 depth(document("partl
ist.xml"))
38
Some Examples(8)
min(), max(), count(), avg(), sum() ltresultsgt L
ET doc document("prices.xml")/prices/book RETU
RN ltcount-of-pricegt count(doc/price)
lt/count-of-pricegt ltavgpricegt
avg(doc/price) lt/avgpricegt ltmaxpricegt
max(doc/price) lt/maxpricegt ltminpricegt
min(doc/price) lt/minpricegt ltsumpricegt
sum(doc/price) lt/sumpricegt lt/resultsgt
39
Some Examples(9)
Another example FOR item IN document("news_item
.xml")//news_item WHERE contains(
string(item/content), "Gorilla Corporation"
) RETURN ltitem_summarygt
item/title/text() ".
item/date/text() ". string(
(item//par)1 ) lt/item_summary
40
Some Examples(10)
Insert, Replace, Delete FOR e IN /empINSERT
ltn_skillsgt count(e/skill) lt/n_skillsgt BEFORE
e/skill1 FOR e IN /empWHERE e/empno
"1234REPLACE e/job WITH ltjobgt "Broom Tester"
lt/jobgt FOR e IN /emp/job "Programmer",
s IN e/skillWHERE s/rating lt 4 OR
s/cert_date lt date("1995-01-01")DELETE s
41
Thank you for your attention
Write a Comment
User Comments (0)
About PowerShow.com