XML and Databases Exercise Session 89 The Systems
XML and Databases Exercise Session 8/9 The Systems Group at ETH Zurich courtesy of Ghislain Fourny © Department of Computer Science | ETH Zürich Friday, September 4 th, 2009
Previously, in XML&Databases Document Well. Formedness XML with namespaces (Validation) (XML Schema) optional Data Model XDM Processing XQuery <a/> Friday, September 4 th, 2009 PUL Algebra Theory 2
XQuery dialects § XQuery core http: //www. w 3. org/TR/xquery/ § XQuery Update Facility http: //www. w 3. org/TR/xquery-update-10/ § XQuery Scripting Extension http: //www. w 3. org/TR/xquery-sx-10/ Friday, September 4 th, 2009 PUL Algebra Theory 3
XQuery dialects XQuery Scripting Extension XQuery Update Facility XQuery 1. 0 Core Friday, September 4 th, 2009 PUL Algebra Theory 4
Reminder: XQuery core let if for order by + else while = any then every return where exit with Expression In XQuery core, anything that goes into or comes out of an expression is a sequence of items! Friday, September 4 th, 2009 PUL Algebra Theory 5
Reminder: XQuery core let any = while e e else r F order by every t c exit with e f f Expression E e d Si if for then + return where In XQuery core, anything that goes into or comes out of an expression is a sequence of items! Friday, September 4 th, 2009 PUL Algebra Theory 6
XQuery Update Facility § Introduces Updating Expressions An updating expression returns a Pending Update List. A PUL is a list of changes that can be applied to your documents at the end of the query. Friday, September 4 th, 2009 PUL Algebra Theory 7
XQuery Update Facility § Introduces Updating Expressions f E e- d i S Friday, September 4 th, 2009 t c fe PUL Algebra Theory e e Fr You will never see changes in the middle of the program (snapshot semantics) 8
Updating expressions § Insert insert node <a/> into $b § Delete delete node $a § Replace replace node $a with <b/> § Rename rename node $a as "b" Friday, September 4 th, 2009 PUL Algebra Theory 9
New non-updating expression § Transform copy $x : = <a/> modify insert node <b/> into $x return $x Friday, September 4 th, 2009 PUL Algebra Theory
XQuery Scripting Extension § Gives XQuery an imperative taste. § Introduces apply expressions (semi-colon with the lowest priority) which apply PULs. insert node <a/> into $b; replace node $b/a with <c/>; § Hence there are side effects! Friday, September 4 th, 2009 PUL Algebra Theory 11
XQuery Scripting Extension Introduces. . . § Variable assignment set $a : = 2; Friday, September 4 th, 2009 PUL Algebra Theory 12
XQuery Scripting Extension Introduces. . . § Blocks block { declare $a : = <a/>; set $a : = <b/>; } Friday, September 4 th, 2009 PUL Algebra Theory 13
XQuery Scripting Extension Introduces. . . § While loops while($i >= 0) { set $i : = $i - 1; } Friday, September 4 th, 2009 PUL Algebra Theory 14
XQuery Fulltext Extension http: //www. w 3. org/TR/xquery-full-text/ Friday, September 4 th, 2009 PUL Algebra Theory 15
XQuery Fulltext Extension § Introduces full text search /books/book contains text "web" ftand "site" ftand "usability" distance at most 2 words Friday, September 4 th, 2009 PUL Algebra Theory 16
XQuery Fulltext Extension § Introduces full text search Friday, September 4 th, 2009 PUL Algebra Theory 17
XQuery Fulltext Extension § Introduces full text search Friday, September 4 th, 2009 PUL Algebra Theory 18
Basic Fulltext Expression: contains text /books/book contains text "web" ftand "site" ftand "usability" search domain (returns sequence of items) fulltext selection (returns All. Matches) The fulltext ftcontains operator returns true if at least one node in the search domain matches the fulltext selection. Friday, September 4 th, 2009 PUL Algebra Theory 19
Primary Fulltext Selection Expressions § "Web site" any § {"Web", "site"} all words occurs 2 times § {"Web", "site"} phrase occurs at most 3 times Friday, September 4 th, 2009 PUL Algebra Theory 20
Primary Fulltext Match Options § "usability" occurs 2 times using stemming § {"Web", "site"} all case sensitive Friday, September 4 th, 2009 PUL Algebra Theory 21
Logical operations § ftand § ftor § ftnot The logical operators and, or, not are prefixed with ft to avoid name collisions with other XQuery logical operations. § not in Friday, September 4 th, 2009 PUL Algebra Theory 22
About Fulltext, Scripting. . . § This is very close to research! § o. Xygen/Saxon do not have this yet. Friday, September 4 th, 2009 PUL Algebra Theory 23
Why no longer ftcontains? (Bug #7247) element ftcontains {'whatever'} Friday, September 4 th, 2009 PUL Algebra Theory 24
Without Fulltext element ftcontains {'whatever'} <ftcontains>whatever</ftcontains> Friday, September 4 th, 2009 PUL Algebra Theory 25
With Fulltext, it could also be. . . context item: <somenode> <element>Write whatever you want. </element> </somenode> element ftcontains {'whatever'} true() Friday, September 4 th, 2009 PUL Algebra Theory 26
MXQuery supports Fulltext java –jar mxquery. jar –fm –f myquery. xquery Friday, September 4 th, 2009 PUL Algebra Theory 27
MXQuery, Zorba, XQIB, XSP, XQDT § Zorba and MXQuery support (a part of) Scripting § They are being developed right here at ETH (and other locations)! § This is new, so not many tools available yet (XQDT, text editor, command line. . . ) § The good thing is: we can correct bugs! Friday, September 4 th, 2009 PUL Algebra Theory 28
Exercise 1 § Design your own full-text queries! Friday, September 4 th, 2009 PUL Algebra Theory 29
Hope to see you next week! Friday, September 4 th, 2009 PUL Algebra Theory 30
- Slides: 30