Introduction to XQuery and eXist Week 21 DSA. DSA - XQuery2 Refresher on XPath XML databases XQuery Applications –Whiskies (again) –A simple blog The.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Advanced XSLT. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
XML: Extensible Markup Language
Java Script Session1 INTRODUCTION.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
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?
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XSLT XML DBs, and Schemas Week 18 DSA. The Whisky Case study XSLT can be applied in the client. –Add a xml processing instruction to the xml to bind to.
DSA Semester 2. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
Native XML Database for Information Systems Chris Wallace IS School Research Seminar Feb 2006.
Week 23 - Revision1 Week 23 Revision DSA. Week 23 - Revision2 Agenda Section A: Multiple choice Section B: Problem-oriented questions Topics for revision.
Introduction to XQuery and eXist XQuery workshop April 2006.
Introduction to XQuery and eXist DSA. XSLT Tutorial Problems Bad language : – No ! – for XML schema –Some XSLT engines tolerant of extra tags (permissive),
Introduction to XQuery and eXist Week 17 DSA. DSA - XQuery2 XPath. Hierarchical file systems have been navigable with path expression since Unix –/abc/cde/../../efg.
XML Workshop XSLT. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
1 COS 425: Database and Information Management Systems XML and information exchange.
Multiple Tiers in Action
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Mannheim Web 2.0 Systems Development. Plan Being an early-adopter Web 2.0 technologies Mashups Google Earth and kml XQuery and eXist.
UFIEKG-20-2 / 06 / Week 131 Data, Schemas and Applications Term 2 Week 13.
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
Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
CSC 405: Web Application And Engineering II 2.1 Web Programming with PHP Introduction to Web programming Introduction to Web programming The programming.
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
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.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
HTML. Principle of Programming  Interface with PC 2 English Japanese Chinese Machine Code Compiler / Interpreter C++ Perl Assembler Machine Code.
Java CGI Lecture notes by Theodoros Anagnostopoulos.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Recursive Functions Creating Hierarchical Reports Date: 9/30/2008 Dan McCreary President Dan McCreary & Associates (952) M.
Database Systems Part VII: XML Querying Software School of Hunan University
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Keyword Searching Weighted Federated Search with Key Word in Context Date: 10/2/2008 Dan McCreary President Dan McCreary & Associates
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
Using oXygen 12 with XQuery Using oXygen to build and execute XQuery XQuery applications on eXist Date: April 2011 Dan McCreary President Dan McCreary.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
XQuery Labs Basic Reporting Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) M D Metadata Solutions.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Homework #4 Forgot we hadn't covered "choose" becomes extra credit My books.xml didn't include descriptions.
CSC 405: Web Application Engineering II 2.1 Web Programming with PHP Introduction to Web programming Introduction to Web programming The programming language.
 Packages:  Scrapy, Beautiful Soup  Scrapy  Website  
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
XML Schema – XSLT Week 8 Web site:
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
XML: Extensible Markup Language
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Querying XML XQuery.
Querying XML XQuery.
PHP.
Tutorial 6 PHP & MySQL Li Xu
More XML XML schema, XPATH, XSLT
EXTENDING COMPONENTS AND TABLE TRANSFORMATIONS WITH XSL
Presentation transcript:

Introduction to XQuery and eXist Week 21 DSA

DSA - XQuery2 Refresher on XPath XML databases XQuery Applications –Whiskies (again) –A simple blog The XQuery Wikibook

DSA - XQuery3 XPath (1) Hierarchical file systems have been navigable with path expression since Unix –/abc/cde/../../efg i.e. ? Problem –Only child, parent and root can be accessed in one step –Only one node addressable

DSA - XQuery4 XPath (2) Solution – extend the path language –select multiple items /abc/cde/../../efg/* - all children of the node /efg //x - all x nodes anywhere in the tree –select a subset of items by appending predicate (filter) – nodes selected if predicate evaluates to true –functions in predicate –multiple filters –select items by position /abc[2] short for /abc[position() = 2]

DSA - XQuery5 XPath (3) Core data type in XPath 2.0 is a sequence of items –Items are atomic values or XML elements –Sequence is flat deep-equal('fred',('fred')) is true deep-equal((‘fred’, ‘fred’), (‘fred’)) is false deep-equal(('fred', ('bill','joe')),('fred', 'bill','joe')) is true –() is the empty sequence count((‘fred’,() )) is 1 Equality between sequences defined as non-empty intersection (‘fred’,’joe’) = ‘joe’ is true (‘fred’,’joe’) = (‘joe’,’bill’) is true (‘fred’,’joe’) eq ‘joe’ is false

DSA - XQuery6 XQuery. Problem –Need to be able to construct a tree as well as select nodes in an existing tree –Need for more complex searches a la SQL Solution 1 – XML addition to existing languages –PHP + Simple XML –XML structures not compatible with language Solution 2 – XSLT –Push (declarative, pattern-matching) or pull processing –XML- based –Two versions 1.0 most common, in Browsers, Xalan 2.0 e.g. Saxon Solution 2 – XQuery –Functional –Pull only –Non XML XQuery 1.0 and XSLT 2.0 share the same XPath 2.0 data model and function library

DSA - XQuery7 eXist Native XML Database Open source Wolfgang Meier is the chief architect Written in Java Deployable in different ways –Embedded in a Java application –Part of a Cocoon pipeline –As web application in Apache/Tomcat –With embedded Jetty HTTPserver (as on stocks) Multiple Interfaces –REST – to Java servlet –SOAP –XML:RPC

DSA - XQuery8 Native XML database Well-formed XML documents can be added to the database They are stored in an efficient, searchable B+ tree structure Documents (files) are organised into collections in a filestore Non-XML resources (XQuery, CSS, JPEG..), etc can be stored as binary

DSA - XQuery9 Whisky example A base XML filebase XML file Some XQuery Scripts Simple list Another simple list Select Whiskies Select with a Form Generate a kml map

DSA - XQuery10 Simple Xquery – list1.xqllist1.xql for $d in //Distillery return {$d/Name} {$d/WhiskyDescription}

DSA - XQuery11 Executing an XQuery eXist DB a.xql XQuery Engine parameters html Client Browser eXist: Server Get a.xql parameters servlet fetch a.xql render User clicks link

DSA - XQuery12 Simple XQuery – list2.xqllist2.xql declare option exist:serialize "method=xhtml media-type=text/html"; Name Address {for $w in //Distillery return {data($w/Name)} {data($w/Address)} }

DSA - XQuery13 declare option exist:serialize "method=xhtml media-type=text/html"; Name Address { for $w in //Distillery return {data($w/Name)} {data($w/Address)} } XQuery explained XQuery ‘variable’ Setting the output mime type XPath expression to select nodes XQuery inside XML Another XPath expression Function to get the text

DSA - XQuery14 XQuery.. Nesting XML and XQuery –XML to XQuery { … } –XQuery to XML … Must be well-formed XML – single root - and handy Constructed structures – XML element or element Position { attribute latitude ’51’, attribute longitude ‘2.5’ } –Sequence ('fred',, 5)

DSA - XQuery15 XQuery.. control constructs are expressions and hence composable –if (cond) then exp else exp –for..let.. where.. order by.. return – FLWOR –function call –variable value ($d) ‘Atomisation’ sometimes needed in output –Element to characters –$d/Name Glenfiddich –data($d/Name) Glenfiddich

DSA - XQuery16 XQuery … Functions and Modules –Typed arguments and return –Recursion –XPath functions –eXist functions Database management HTTP interface.. Functional language –let $x := 5 binds the value 5 to the variable $x –Can’t write iterative code – what’s the output? let $y := 1 return for $x in (1 to 5) let $y := $y * 2 return $y

DSA - XQuery17 XQuery FLWOR expression FLWOR for $x in sequence let $a := expression, $b := expression where condition order by $var return expression –Returns a Sequence of nodes Compare with SQL select columns from tables where condition order by –Returns a Relation (table)

DSA - XQuery18 Search Query Enter a name or part name Match against the Distillery name List the matches

DSA - XQuery19 List 3 let $name := request:request-parameter("name","") return Name Address {for $d in //Distillery[contains(Name,$name)] return {data($d/Name)} {data($d/Address)} } eXist function F L WO R expression

DSA - XQuery20 An XQuery sticky form The script here has several shifts between XML to XQuery Whole interface in one script –Equivalent to PHP + MySQL.

DSA - XQuery21 let $name := request:request-parameter("name","") return Enter Name or part of Name Name Address { for $d in //Distillery[contains(Name,$name)] return {data($d/Name)} {data($d/Address)} } list4.xql

DSA - XQuery22 Generate a kml overlay Output is kml Need to specify the mime type so that the browser will link to Google Earth (if set up correctly) Or create a Google Map link: uwe.ac.uk/xmlwiki/whisky/map.xqlhttp://maps.google.com/maps?q= uwe.ac.uk/xmlwiki/whisky/map.xql

DSA - XQuery23 Kml declare option exist:serialize "method=xhtml indent=yes media-type=application/vnd.google-earth.kml+xml"; Distilleries of Scotland 2 {for $d in //Distillery return {data($d/Name)} {data($d/WhiskyDescription)} } distkml.xql

Reading an API Brooklyn Museum APIAPI Simple search –Returning XMLReturning XML –Returning HTMLReturning HTML DSA - XQuery24

Source DSA - XQuery25 let $uri := " let $apikey := "yPbZKsKZLC" let $keyword:= request:get-parameter("keyword","Anubis") let $request := concat($uri,"?api_key=",$apikey,"&version=1&include_it em_caption=true&require_image=true&method=collectio n.search&keyword=",$keyword) return doc($request)

Uploading DSA CW2 metadata upload.xql DSA - XQuery26

FOLD and StudentsOnline StudentsOnline DSA - XQuery27

DSA - XQuery28 XQuery Wikibook A large number of worked examples –

DSA - XQuery29 Trying eXist Demo site – Local installation –Simple install from the exist-db site –Use the Java client to load files move, copy, rename files edit files in situ (but no Save-as) execute queries backup

Other Native XML databases MarkLogic –MarkMail Sedna Berkleydb Many Relational databases include partial support for XML DSA - XQuery30