SDPL 20077: Querying XML with XQuery1 7 Querying XML n How to access XML data sources? n XQuery, XML Query Lang, W3C Rec, 01/ '07 –joint work by XML Query.

Slides:



Advertisements
Similar presentations
Advanced XSLT. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
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: Extensible Markup Language
XML May 3 rd, XQuery Based on Quilt (which is based on XML-QL) Check out the W3C web site for the latest. XML Query data model –Ordered !
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
XQuery Or, what about REAL databases?. XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer.
XQUERY. What is XQuery? XQuery is the language for querying XML data The best way to explain XQuery is to say that XQuery is to XML what SQL is to database.
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?
Database Management Systems, R. Ramakrishnan1 Introduction to Semistructured Data and XML Chapter 27, Part D Based on slides by Dan Suciu University of.
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.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 7. XQuery.
A Graphical Environment to Query XML Data with XQuery
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 357 Database Systems I Query Languages for XML.
XQL (XML Query Language) Jonathan Robie (Software AG) Eduard Derksen (CSCIO) Peter Fankhauser (GMD-IPSI) Ed Howland (DEGA) Gerald Huck (GMD-IPSI) Ingo.
XQuery language Presented by: Tayeb sbihi supervised by: Dr. H. Haddouti.
1 COS 425: Database and Information Management Systems XML and information exchange.
Query Languages - XQuery Slides partially from Dan Suciu.
SDPL 2001Notes 8.2: XQuery1 8.2 W3C XML Query Language –Thanks for Helena Ahonen-Myka (University of Helsinki) for borrowing her slide originals for this.
XQuery – The W3C XML Query Language Jonathan Robie, Software AG Don Chamberlin, IBM Research Daniela Florescu, INRIA.
Cornell CS 502 More XML XML schema, XPATH, XSLT CS 502 – Carl Lagoze – Cornell University.
XML QUERY LANGUAGE Prepared by Prof. Zaniolo, Hung-chih Yang, Ling-Jyh Chen Modified by Fernando Farfán.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Querying XML February 12 th, Querying XML Data XPath = simple navigation through the tree XQuery = the SQL of XML XSLT = recursive traversal –will.
Processing of structured documents Spring 2003, Part 8 Helena Ahonen-Myka.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
Advisor: Prof. Zaniolo Hung-chih Yang Ling-Jyh Chen XML Query Language.
Xquery. Summary of XQuery FLWR expressions FOR and LET expressions Collections and sorting Resource W3C recommendation:
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
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.
Introduction to XQuery Resources: Official URL: Short intros:
XML-QL A Query Language for XML Charuta Nakhe
SDPL 20067: Querying XML with XQuery1 7 Querying XML n How to access data sources as XML? n XQuery, W3C XML Query Language –Candidate Rec, November 2005.
SDPL Querying XML with XQuery1 5 Querying XML n How to access various XML data sources? n XQuery, XML Query Lang, W3C Rec, Jan '07 –joint work by.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
Structured-Document Processing Languages Spring 2011 Course Review Repetitio mater studiorum est!
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.
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.
A Quilt, not a Camel Don Chamberlin Jonathan Robie Daniela Florescu May 19, 2000.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
Introduction to XQuery Bun Yue Professor, CS/CIS UHCL.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XQL, OQL and SQL Xia Tang Sixin Qian Shijun Shen Feb 18, 2000.
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Nikos dimitrakas – IS4/2i1242/2i4042 spring XML Query Languages Database Systems (4th edition) Chapter 30.5, , Articles & Excerpts.
Database Systems Part VII: XML Querying Software School of Hunan University
SDPL 2002Notes 9: XQuery1 9 Querying XML Data and Documents n XQuery, W3C XML Query Language –"work in progress", Working Draft, 30 April 2002 –joint work.
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.
[ 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.
1 XML Data Management XPath Principles Werner Nutt.
CBU 2007XQuery and XPath1 W3C XML Query n How to access various XML data sources? n XQuery, XML Query Lang, W3C Rec, Jan '07 –joint work by XML Query and.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
IS432 Semi-Structured Data Lecture 6: XQuery Dr. Gamal Al-Shorbagy.
19 th International Unicode Conference San Jose, CA September W3C XML Query Paul Cotton, Microsoft 19 th Unicode Conference Sept 12, 2001.
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
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 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
SDPL 2005Notes 7: XQuery1 7 Querying XML n How to access different sources (DBs, docs) as XML? n XQuery, W3C XML Query Language –"work in progress", (last.
Query Languages for XML
Querying and Transforming XML Data
8 Querying XML How to access different sources (DBs, docs) as XML?
XQuery Leonidas Fegaras.
More XML XML schema, XPATH, XSLT
Presentation transcript:

SDPL 20077: Querying XML with XQuery1 7 Querying XML n How to access XML data sources? n XQuery, XML Query Lang, W3C Rec, 01/ '07 –joint work by XML Query and XSL WGs »with XPath 2.0 and XSLT 2.0 –influenced by many research groups and query languages »Quilt, XPath, XQL, XML-QL, SQL, OQL, Lorel,... –A query language for any XML-represented data: both documents and databases

SDPL 20077: Querying XML with XQuery2 Functional Requirements (1) n Support operations (selection, projection, aggregation, sorting, etc.) on all data types: –Choose data based on content or structure –Operate on document hierarchy and order n Structural preservation and transformation: –Preserve relative hierarchy and sequence of input structures –Transform XML structures, and create new n Combining and joining: –Combine data from different parts of a document, or from multiple documents

SDPL 20077: Querying XML with XQuery3 Functional Requirements (2)  Closure property: –Results of XML queries are also XML (well-formed document fragments) –> queries can be combined without limit n Extensibility: –should support externally defined functions on all data types of the data model

SDPL 20077: Querying XML with XQuery4 XQuery in a Nutshell n Functional expression language n Strongly-typed: (optional) type-checking of expressions, and validation of results (We’ll concentrate to processing) –predeclared prefix for type names: xs= n Extends XPath 2.0 –XQuery 1.0 and XPath 2.0 Functions and Operators, Rec. Jan n XQuery  XPath' + XSLT' + SQL' (roughly)

SDPL 20077: Querying XML with XQuery5 Example Query xquery version "1.0"; Cheap Books { for $b in Cheap Books { for $b in  XML-based syntax (XQueryX) also specified  Syntax "concise and easily understood"

SDPL 20077: Querying XML with XQuery6 A possible result Cheap Books Computing with Logic David Maier Benjamin Cummings 1999 Designing Internet applications Michael Leventhal Prentice Hall 1998 Cheap Books Computing with Logic David Maier Benjamin Cummings 1999 Designing Internet applications Michael Leventhal Prentice Hall 1998

SDPL 20077: Querying XML with XQuery7 XQuery: Basics n A query is an expression (lauseke) n Expressions operate on, and return sequences of –atomic values (of XML Schema simple types) and –nodes (of 6 types = XPath node types – NS nodes) –an item  a singleton sequence –sequences are flat: no sequences as items »(1, (2, 3), (), 1) = (1, 2, 3, 1) –sequences are ordered, and can contain duplicates n Unlimited combination of expressions, often with automatic type conversions (e.g. for arithmetics)

SDPL 20077: Querying XML with XQuery8 XQuery: Accessing Documents n XQuery operates on nodes accessible by input functions –fn:doc(" URI ") »document-node of the XML document available at URI »same as document(" URI ") in XSLT 1.0 –fn:collection(" URI ") »sequence of nodes from URI –predeclared prefix for the default function namespace: fn=

SDPL 20077: Querying XML with XQuery9 Central XQuery Expressions n Path expressions n Sequence expressions n Comparison operators n Quantified expressions (some/every $x… in … satisfies …) n Element constructors (  XSLT templates) n FLWOR expressions (”flower”; for-let-where-order by-return) n and others, in examples... also in XPath 2.0

SDPL 20077: Querying XML with XQuery10 Path Expressions n Similar to XPath 1.0: [/]Expr/… /Expr –but steps more liberal: –arbitrary (node-sequence valued) expressions OK –6 (of 13 XPath) axes: child, descendant, attribute, self, descendant-or-self, parent »others (except namespace ) available if Full Axis Feature supported »with document-order operators ( >) sufficient for expressing queries (→ Exercises) –produce a sequence of nodes in document order, without duplicates

SDPL 20077: Querying XML with XQuery11 Sequence Expressions n Constant sequences constructed by listing values –comma (, ) is a catenation operator »(1, (2, 3), (), 1) = (1, 2, 3, 1) n Also dynamically generated: –(, $emp/child, ) n Shorthands for numeric sequences: –1 to 4 –4 to 1 –fn:reverse(1 to 4)  (1, 2, 3, 4)  ()  (4, 3, 2, 1)

SDPL 20077: Querying XML with XQuery12 Set Operations on Node (!) Sequences n Assume variable bindings: $s2 n Then: $s1 $s1 union $s2 = $s1 intersect $s2 = $s1 except $s2 = based on node indentity ( node 1 is node 2 ) abcde abcde c ab

SDPL 20077: Querying XML with XQuery13 Node Comparisons n To compare single nodes, –for identity: is is ($book//chap)[1] true iff the chapter with id="ch1" is indeed the first –for document order: > >> $book//title[. eq "Intro"] true iff the chapter with id="ch2" appears after Intro >> $book//title[. eq "Intro"] true iff the chapter with id="ch2" appears after Intro

SDPL 20077: Querying XML with XQuery14 Comparing values of sequences and items n General comparisons btw sequences: –=, !=,, >= –existential semantics: true iff some pair of values from operand sequences satisfy the condition »(1,2) = (2,3); (2,3) = (3,4); (1,2) != (3,4) »Same as in XPath 1.0: //book[author = "Aho"] → books where some author is Aho n Value comparisons btw single values: –eq, ne, lt, le, gt, ge »1 eq 3 - 2; 10 lt 20; le 100]

SDPL 20077: Querying XML with XQuery15 Filter Expressions Location steps can be filtered by predicates: $book//(chap | app)[fn:last()]/title Location steps can be filtered by predicates: $book//(chap | app)[fn:last()]/title the title of the last chapter of appendix, whichever is last the title of the last chapter of appendix, whichever is last Other sequences, too: (1 to 20)[. mod 5 eq 0] → (5, 10, 15, 20) Other sequences, too: (1 to 20)[. mod 5 eq 0] → (5, 10, 15, 20) –('. ' generalized from XPath 1.0 shorthand for self::node() into the context item) XPath 2.0 extended step

SDPL 20077: Querying XML with XQuery16 Element Constructors n Similar to XSLT templates: –start and end tag enclosing the content –literal fragments written directly, expressions enclosed in braces { and } ≈ XSLT 1.0 attribute value templates n often used inside another expression that binds variables used in the element constructor –(There is no 'current node' in XQuery) –See next

SDPL 20077: Querying XML with XQuery17 Example An emp element with an empid attribute and child elements name and job, from values in variables $id, $n, and $j : An emp element with an empid attribute and child elements name and job, from values in variables $id, $n, and $j : {$n} {$n} {$j} {$j} </emp> Also computed constructors: element {"emp"} { attribute {"empid"}{$id}, {$n}, {$j} }

SDPL 20077: Querying XML with XQuery18 FLWOR ("flower") Expressions n Constructed from for, let, where, order by and return clauses (~SQL select-from-where) n Syntax: (ForClause | LetClause)+ WhereClause? OrderByClause? "return" Expr n FLWOR binds variables to values, and uses these bindings to construct a result (an ordered sequence of items)

SDPL 20077: Querying XML with XQuery19 Flow of data in a FLWOR expression

SDPL 20077: Querying XML with XQuery20 for clauses for $V 1 in Exp 1 (, $V 2 in Exp 2, …) for $V 1 in Exp 1 (, $V 2 in Exp 2, …) –associates each variable V i with expression Exp i (e.g. a path expression) n Result: list of tuples, each containing a binding for each of the variables n can be though of as loops iterating over the items returned by respective expressions

SDPL 20077: Querying XML with XQuery21 Example: for clause for $i in (1,2), $j in (1 to $i) return {$i} {$j} for $i in (1,2), $j in (1 to $i) return {$i} {$j} Result:<tuple><i>1</i><j>1</j></tuple><tuple><i>2</i><j>1</j></tuple><tuple><i>2</i><j>2</j></tuple>

SDPL 20077: Querying XML with XQuery22 let clauses n let also binds variables to expressions –each variable gets the entire sequence as its value (without iterating over the items of the sequence) –results in binding a single sequence for each variable n Compare: –for $b in doc("bib.xml")//book  many bindings (to single books) –let $bl := doc("bib.xml")//book  a single binding (to sequence of books)

SDPL 20077: Querying XML with XQuery23 Example: let clauses let $s := (,, ) return {$s} return {$s} Result:<out> </out> for $s in (,, ) return {$s} return {$s} --> -->

SDPL 20077: Querying XML with XQuery24 for/let clauses n A FLWOR expr may contain several fors and lets –each may refer to variables bound in previous clauses n the result of the for/let sequence: –an ordered list of tuples (monikko) of bound variables –number of tuples = product of the cardinalities of the sequences returned by the for expressions

SDPL 20077: Querying XML with XQuery25 where clause n binding tuples generated by for and let clauses are filtered by an optional where clause –tuples with a true condition are used to instantiate the return clause the where clause may contain several predicates connected by and, or, and fn:not() the where clause may contain several predicates connected by and, or, and fn:not() –usually refer to the bound variables –sequences as Booleans (similarly to node-sets in XPath 1.0): empty ~ false; non-empty ~ true

SDPL 20077: Querying XML with XQuery26 where clause n for binds variables to single items  value comparisons, e.g. $color eq " red "  value comparisons, e.g. $color eq " red " let to whole sequences  general comparisons, e.g. $colors = "red" ( ~ some $c in $colors satisfies $c eq "red" ) let to whole sequences  general comparisons, e.g. $colors = "red" ( ~ some $c in $colors satisfies $c eq "red" ) –a number of aggregation functions available: avg(), sum(), count(), max(), min() (also in XPath 1.0)

SDPL 20077: Querying XML with XQuery27 return clause n The return clause generates the output of the FLWOR expression n instantiated once for each binding tuple n often contains element constuctors, references to bound variables, and nested sub-expressions

SDPL 20077: Querying XML with XQuery28 Example: for + return for $i in (1,2), $j in (1 to $i) return {$i} {$j} for $i in (1,2), $j in (1 to $i) return {$i} {$j} Result:<tuple><i>1</i><j>1</j></tuple><tuple><i>2</i><j>1</j></tuple><tuple><i>2</i><j>2</j></tuple>

SDPL 20077: Querying XML with XQuery29 Examples (modified from "XML Query Use Cases") Assume: a document named ” bib.xml ” containing of a list of book s: + + Assume: a document named ” bib.xml ” containing of a list of book s: + +

SDPL 20077: Querying XML with XQuery30 { { } } List Morgan Kaufmann book titles since 1998 for $b in doc(”bib.xml”)//book where $b/publisher = ”Morgan Kaufmann” and $b/year >= 1998 and $b/year >= 1998 return return {$b/title}

SDPL 20077: Querying XML with XQuery31 Result could be... <recent-MK-books> TCP/IP Illustrated TCP/IP Illustrated Advanced Programming in the Unix environment Advanced Programming in the Unix environment </recent-MK-books>

SDPL 20077: Querying XML with XQuery32 Publishers with avg price of their books: for $p in fn:distinct-values( fn:doc(”bib.xml”)//publisher ) let $a := avg( doc(”bib.xml”)//book[ publisher = $p]/price ) return {$p} {$a} return {$p} {$a} string values of the sequence, without duplicates

SDPL 20077: Querying XML with XQuery33 Invert the book-list structure { (: group books by authors :) { (: group books by authors :) for $a in distinct-values( doc(”bib.xml”)//author ) for $a in distinct-values( doc(”bib.xml”)//author ) return { return { {$a}, {$a}, for $b in doc(”bib.xml”)//book[ for $b in doc(”bib.xml”)//book[ author = $a] return $b/title } return $b/title } } }

SDPL 20077: Querying XML with XQuery34 List of publishers alphabetically, and their books in descending order of price for $p in distinct-values( doc(”bib.xml”)//publisher ) order by $p return {$p} { for $b in doc(”bib.xml”)//book[ {$p} { for $b in doc(”bib.xml”)//book[ publisher = $p] order by $b/price descending return {$b/title, return {$b/title, $b/price} } $b/price} }

SDPL 20077: Querying XML with XQuery35 Queries on Document Order n Operators >: –x > x similarly) n Consider a surgical report with –procedure elements containing »incision sub- elements n Return a "critical sequence" of contents between the first and the second incisions of the first procedure

SDPL 20077: Querying XML with XQuery36 Computing a "critical sequence" { { let $p := (doc("report.xml")//procedure)[1] let $p := (doc("report.xml")//procedure)[1] for $n in $p/node() for $n in $p/node() where $n >> ($p//incision)[1] and $n > ($p//incision)[1] and $n << ($p//incision)[2] return $n } return $n } NB: if incision s are not children of the procedure, then an ancestor of the second incision gets to the result; How to avoid this? NB: if incision s are not children of the procedure, then an ancestor of the second incision gets to the result; How to avoid this?

SDPL 20077: Querying XML with XQuery37 User-defined functions: Example declare function local:precedes($a as node(), $b as node()) as xs:boolean { $a << $b and (: $a is no ancestor of $b: :) empty($a//node() intersect $b) }; empty($a//node() intersect $b) }; local : is predeclared prefix for the namespace of local function names local : is predeclared prefix for the namespace of local function names –Alternatively: declare namespace my= declare namespace my= declare function my:precedes(... (as above)

SDPL 20077: Querying XML with XQuery38 User-defined functions: Example Now, ”critical sequence” without ancestors of incision : Now, ”critical sequence” without ancestors of incision : { { let $p := (doc("report.xml")//procedure)[1] let $p := (doc("report.xml")//procedure)[1] for $n in $p/node() for $n in $p/node() where $n >> ($p//incision)[1] and local:precedes($n, ($p//incision)[2]) where $n >> ($p//incision)[1] and local:precedes($n, ($p//incision)[2]) return $n return $n } }

SDPL 20077: Querying XML with XQuery39 Recursive Transformations n Example: “Table-of-contents” for nested sections –NB if-then-else (in ordinary XPath 2.0 expressions, too) declare namespace my= declare function my:toc( $n as element() ) as element()* { if (name($n)=”sect”) then { then { for $c in $n/* return my:toc($c) } for $c in $n/* return my:toc($c) } else if (name($n)=”title”) then $n else if (name($n)=”title”) then $n else (: check child elements, if any: :) for $c in $n/* return my:toc($c) }; else (: check child elements, if any: :) for $c in $n/* return my:toc($c) };

SDPL 20077: Querying XML with XQuery40 Querying relational data n Lots of data is stored in relational databases n Should be able to access also them n Example: Tables for Parts and Suppliers –P ( pno, descrip ) : part numbers and descriptions –S ( sno, sname ) : supplier numbers and names –SP ( sno, pno, price ): who supplies which parts and for what price?

SDPL 20077: Querying XML with XQuery41 Possible XML representation of relations * * *

SDPL 20077: Querying XML with XQuery42 Selecting in SQL vs. XQuery n SQL: n XQuery: SELECT pno FROM p WHERE descrip LIKE ’Gear%’ ORDER BY pno; for $p in doc(”p.xml”)//p_tuple where starts-with($p/descrip, ”Gear”) order by $p/pno return $p/pno

SDPL 20077: Querying XML with XQuery43 Grouping n Many queries involve grouping data and applying aggregation function like count or avg to each group n in SQL: GROUP BY and HAVING clauses n Example: Find the part number and average price for parts with at least 3 suppliers

SDPL 20077: Querying XML with XQuery44 Grouping: SQL SELECT pno, avg(price) AS avgprice FROM sp GROUP BY pno HAVING count(*) >= 3 ORDER BY pno;

SDPL 20077: Querying XML with XQuery45 Grouping: XQuery for $pn in distinct-values( doc(”sp.xml”)//pno) let $sp:=doc(”sp.xml”)//sp_tuple[pno=$pn] where count($sp) >= 3 order by $pn return { { {$pn}, {$pn}, {avg($sp/price)} {avg($sp/price)} } }

SDPL 20077: Querying XML with XQuery46 Joins n Example: Return a ”flat” list of supplier names and their part descriptions, in alphabetic order for $sp in doc(”sp.xml”)//sp_tuple, $p in doc(”p.xml”)//p_tuple[pno = $sp/pno], $p in doc(”p.xml”)//p_tuple[pno = $sp/pno], $s in doc(”s.xml”)//s_tuple[sno = $sp/sno] $s in doc(”s.xml”)//s_tuple[sno = $sp/sno] order by $p/descrip, $s/sname return { $s/sname, $s/sname, $p/descrip $p/descrip } }

SDPL 20077: Querying XML with XQuery47 XQuery vs. XSLT 1.0 n Could we express XQuery queries with XSLT? –In principle yes, always, (but could be tedious) n Partial XSLT simulation of FLWOR expressions: XQuery : for $x in Expr …rest of query can be expressed in XSLT as : can be expressed in XSLT as : … translation of the rest of the query … translation of the rest of the query

SDPL 20077: Querying XML with XQuery48 XQuery vs. XSLT 1.0 XQuery : let $y := Expr … corresponds directly to : corresponds directly to : and where Condition … rest  … translation of the rest … translation of the rest

SDPL 20077: Querying XML with XQuery49 XQuery vs. XSLT 1.0 XQuery : return ElemConstructor can be simulated with a corresponding XSLT template: static fragments as such static fragments as such enclosed expressions in element content, e.g. {$s/sname} become enclosed expressions in element content, e.g. {$s/sname} become

SDPL 20077: Querying XML with XQuery50 XQuery vs. XSLT 1.0: Example for $b in doc(”bib.xml”)//book where $b/publ = ”MK” and $b/year > 1998 return return {$b/title} {$b/title} XQuery: 1998”> 1998”> 

SDPL 20077: Querying XML with XQuery51 XSLT for XQuery FLWOR Expressions n NB: The sketched simulation is not complete: –Only two things, roughly, can be done with XSLT 1.0 result tree fragments produced by templates: »insertion in result tree - with and conversion to a string - with »insertion in result tree - with and conversion to a string - with –Not possible to apply other operations to results (like, e.g., sorting in XQuery): for $y in ( {$x/code},... ) order by $y/key

SDPL 20077: Querying XML with XQuery52 XQuery: Summary –A recent W3C XML query language, also capable of general XML processing –Vendor support?? » mentions ~ 50 prototypes or products (2004: ~ 30, 2005: ~ 40; free, commercial,... Oracle, IBM) –Future?? Interesting confluence of document and database research, and highly potential for XML-based data integration