Dickson K.W. Chiu PhD, SMIEEE Thanks to Prof. Francis Lau (HKU)

Slides:



Advertisements
Similar presentations
XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
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
ISO DSDL ISO – Document Schema Definition Languages (DSDL) Martin Bryan Convenor, JTC1/SC18 WG1.
XQuery John Annechino Steven Pow. Agenda What is XQuery? Uses of XQuery XQuery vs. XSLT Syntax –Built-In Functions –FLWOR –if-then-else –User-Defined.
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.
XLink Van Lepthien CSCI 7818 Fall Overview What is XLink? W3C Stuff XLink Elements Linkbases Traversals Implementations Comments References.
1 COS 425: Database and Information Management Systems XML and information exchange.
XQuery – The W3C XML Query Language Jonathan Robie, Software AG Don Chamberlin, IBM Research Daniela Florescu, INRIA.
XLink: Open Linking Standard XML / XSL separate  data semantics  presentation semantics Need to also separate out  navigation semantics Single unique.
Cornell CS 502 More XML XML schema, XPATH, XSLT CS 502 – Carl Lagoze – Cornell University.
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.
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.
W3C XML Query Language Working Group Mark Needleman Data Research Associates ZIG Current Awareness Session July 13, 2000.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
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.
Neminath Simmachandran
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
Xpath Xlink Xpointer Xquery Sources:
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
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.
WORKING WITH XSLT AND XPATH
Session II Chapter 2 – Chapter 2 – XSLhttp://
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.
Pointers in the TEI Current issues 3 octobre 2004.
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.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
XQL, OQL and SQL Xia Tang Sixin Qian Shijun Shen Feb 18, 2000.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XML Part 2 Josh Steele CS 6704, Spring XML Part 2 XSL/XSLT –Structure Revisited –Definition –Example –Components XML’s Linking Languages XML’s Uses.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 XML An Overview Roger Debreceny University of Hawai`i Skip White University of Delaware XBRL Workshop, August 2006.
Processing of structured documents. XML Linking Language (XLink) zCreate and describe links between resources zboth basic unidirectional links and more.
Database Systems Part VII: XML Querying Software School of Hunan University
XLinks Praveen Polishetty. Contents : XLink Capabilities XLink Concepts XLink Core Properties XLink Semantic Properties XLink Behavior Properties XLink.
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.
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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types.
Interoperability How to Build a Digital Library Ian H. Witten and David Bainbridge.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Linking XML Documents Ellen Pearlman Eileen Mullin Programming the Web.
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.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
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.
XML: Extensible Markup Language
Querying and Transforming XML Data
XML QUESTIONS AND ANSWERS
Chapter Eight Interoperability How to Build a Digital Library
{ XML Technologies } BY: DR. M’HAMED MATAOUI
More XML XML schema, XPATH, XSLT
New Perspectives on XML
Presentation transcript:

Dickson K.W. Chiu PhD, SMIEEE Thanks to Prof. Francis Lau (HKU) CSIT600b: XML Programming Xlink, XPointer, XQuery Dickson K.W. Chiu PhD, SMIEEE Thanks to Prof. Francis Lau (HKU)

Problem of HTML Linking Growth of the “Web” attributed to the ability of an HTML page to (hyper)link to another page <a href=http://www.ust.hk/> … Limitations Involves only two resources One-way (the “back” button is a browser’s thing) The source must be HTML The whole document is loaded even if your link points to a section <img src=“http://www.dot.com#jpg5”> … The target page must contain explicit section markups Dickson Chiu-2004

XML Linking XLink to link resources, XPointer to point to fragments of XML documents Tutorial: http://zvon.org/xxl/xlink/OutputExamples/xlinksimple_intro.html W3C Recommendation 1.0, Jun 2001 Example One-way and two-way One link, involving 4 resources Information about this link can be in a completely separated file A.html B.xml C.html D.xml Dickson Chiu-2004

XLink Example XLink’s global attributes <name xmlns=“http://dot.com/name” xmlns:xlink=“http://www.w3.org/1999/xlink”> <first>Tommy</first> <last xlink:type=“simple” xlink:href=“http://dot.com/~tlee”>Lee</last> </name> XLink’s global attributes type, href, label, role, arcrole, title, show, actuate, from, to Can be added to elements that are in any arbitrary namespace Dickson Chiu-2004

The “type” Attribute Mandatory, to define a link Six types (the first 2 are link types, the others are for providing more info about a link) Simple Extended Title – to provide human-readable titles Locator – to indicate remote resources Resource – to define local resources involved Arc – to indicate the rules for traversing Dickson Chiu-2004

“title”, “label”, and “role” title and label are used to label the functions of various resources in the link label is machine-readable, title human-readable <last xlink:label=“lastName” xlink:type=“simple” xlink:href=“people.xml” xlink:title=“Last name” xlink:role=“http://dot.com/names”>Last name </last> role is a URI that references a resource that describes the meaning of the link Dickson Chiu-2004

“actuate” and “show” The actuate attribute specifies when the resource should be retrieved onLoad (default) onRequest The show attribute specifies how to display the resource when it is loaded new – new window replace – current window embed (default) – insert here like <html:img src=... > The application can provide other values, using “QNames”, but the application should know how to handle them xlink:actuate=“op:EveryFiveMinutes” Dickson Chiu-2004

“from” and “to” A link can involve multiple resources, and be traversed in multiple directions <element xlink:from=“myapp:first” xlink:to=“myapp:last” xlink:show=“replace” xlink:actuate=“onRequest”> Click for last</element> When clicked, the first link resource will be replaced by the last link resource Dickson Chiu-2004

Simple Links Like HTML links: 2 resources <element xlink:type=“simple” xlink:href=… xlink:show=“new”>Click me!</element> Simple links are “inline” links because the link’s own content (i.e., “Click me”) is the resource Dickson Chiu-2004

Extended Links An element to describe links among sets of document(s), classified by labels Extended links can be “out of line” You could create a link from A to B even though you have no access rights for A and B Locator-type to indicate remote resources, and arc-type to specify rules for traversals Attribute arcrole is used to describe the relationship between the resources Dickson Chiu-2004

Extended Links Example <extendedlink xlink:type="extended"> <loc xlink:type="locator" xlink:href="..." xlink:label="parent" xlink:title="p1" /> <loc xlink:type="locator" xlink:href="..." xlink:label="parent" xlink:title="p2" /> <loc xlink:type="locator" xlink:href="..." xlink:label="child" xlink:title="c1" /> <loc xlink:type="locator" xlink:href="..." xlink:label="child" xlink:title="c2" /> <loc xlink:type="locator" xlink:href="..." xlink:label="child" xlink:title="c3" /> ... <!-- arc-type elements would go here --> </extendedlink> <go xlink:type=“pararc" xlink:from="parent" xlink:to="child" /> links from parents to children (6 links total) <go xlink:type=“childarc" xlink:to="child" /> links from parents to children and children to children (15 links total) Upon clicking on a item, say “p1”, the rendering software (need not be a browser) displays a list of linked items for the user to choose. Dickson Chiu-2004

XPointer Provides a method for pointing to pieces of an XML document W3C Recommendation 1.0, Mar 2003 Built on XPath, with the following extensions Locate information by string matching Can be appended to URI’s Address not only entire nodes, but pieces of nodes in an XML document Finer than nodes A location is any node type allowed in Xpath A point is any spot in the XML document A range is defined by two points Dickson Chiu-2004

XInclude and XBase XML 1.0 / 1.1 does not have “include’s” XInclude uses XPointer to include portions of another document The parse attribute has value xml (parsed) or text (unparsed) XBase is for providing base URI’s for relative links in a document Dickson Chiu-2004

XQuery XQuery is a language for querying XML data XQuery is built on XPath expressions XQuery for XML is like SQL for databases http://www.w3c.org/XML/Query Updated release of the XQuery 1.0, XPath 2.0: W3C Oct 2004 XQuery is not an XML language - a version in XML syntax is called XQueryX. Tutorial booklet download from DataDirect: http://www.datadirect.com/news/whatsnew/xquerybook/index.ssp Brief tutorials: http://www.brics.dk/~amoeller/XML/index.html http://www.w3schools.com/xquery/default.asp Dickson Chiu-2004

XQuery W3C Requirements at least one XML syntax (at least one human-readable syntax) must be declarative must be protocol independent must respect XML data model must be namespace aware must coordinate with XML Schema must work even if schemas are unavailable must support simple and complex datatypes must support universal and existential quantifiers must support operations on hierarchy and sequence of document structures must combine information from multiple documents must support aggregation must be able to transform and to create XML structures must be able to traverse ID references Dickson Chiu-2004

XQuery Basic Concepts Expressions are evaluated relative to a context: namespaces variables functions date and time context item (current node or atomic value) context position (in the sequence being processed) context size (of the sequence being processed) A query in XQuery is an expression that: reads a sequence of XML fragments or atomic values returns a sequence of XML fragments or atomic values The principal forms of XQuery expressions are: path expressions (same as XPath) element constructors FLWOR ("flower") expressions list expressions conditional expressions quantified expressions datatype expressions Dickson Chiu-2004

XQuery Path Expressions The simplest kind of query is just an XPath 2.0 expression. Example: document("recipes.xml")// recipe[title="Ricotta Pie"]// ingredient[@amount] Some XQuery specific extension of XPath: location steps may follow a new IDREF axis an arbitrary XQuery expression may be used as a location step Dickson Chiu-2004

XPath 2.0 Major Changes from 1.0 now using XML Schema primitive types instead of just node-set, boolean, number, string new type operators: cast, treat, assert, instance of now using sequences instead of node-sets also allow non-node types new operators: for, if, some, every, intersect, except many new functions regular expression match/replace/tokenize date formats ... Dickson Chiu-2004

XQuery FLWOR expressions The main engine of XQuery is FLWOR expression For-Let-Where-Order-Return pronounced "flower" generalizes SELECT-FROM-HAVING-WHERE from SQL Example for $d in document("depts.xml")//deptno let $e := document("emps.xml")//employee[deptno = $d] where count($e) >= 10 order by avg($e/salary) descending return <big-dept> { $d, <headcount>{count($e)}</headcount>, <avgsal>{avg($e/salary)}</avgsal> }</big-dept> For – loop Let – binding once Only 1 where { … } – list expression Dickson Chiu-2004

XQuery FLWOR Join Example Sufficient to compute joins of documents – example: for $p IN document("www.irs.gov/taxpayers.xml")//person for $n IN document("neighbors.xml")//neighbor[ssn = $p/ssn] return <person> <ssn> { $p/ssn } </ssn> { $n/name } <income> { $p/income } </income> </person> Dickson Chiu-2004

XQuery List Expression XQuery expressions manipulate lists of values, for which many operators are supported: constant lists: (7, 9, <thirteen/>) integer ranges: i to j XPath expressions, like all named children of the context node: name concatenation: , set operators: | (or union), intersect, except functions: remove, index-of, count, avg, max, min, sum, distinct-values ... When lists are viewed as sets: XML nodes are compared on node identity duplicates are removed the order is preserved Dickson Chiu-2004

XQuery Qualified Expression some-in-satisfies for $b in document("bib.xml")//book where some $p in $b//paragraph satisfies (contains($p,"sailing") AND contains($p,"windsurfing")) return $b/title every-in-satisfies where every $p in $b//paragraph satisfies contains($p,"sailing") Dickson Chiu-2004

XQuery Datatype Expression XQuery supports all datatypes from XML Schema, both primitive and complex types. Constant values can be written: as literals (like string, integer, float) as constructor functions (true(), date("2001-06-07")) as explicit casts (cast as xsd:positiveInteger(47)) Arbitrary XML Schema documents can be imported into a query. An instance of operator allows runtime validation of any value relative to a datatype or a schema. A typeswitch operator allows branching based on types. Dickson Chiu-2004

XQuery - Other Features Hundreds of built-in operators and functions - contains anything you might think of Computed element and attribute names - allow more flexible queries User-defined functions - allow general-purpose computations Views and updates are still under development Dickson Chiu-2004

Status (updated) Software? Starting to come up http://www.w3.org/XML/Linking XLink 1.0 and Xbase 1.0 - June 27, 2001 XPointer 1.0 - 25 March 2003 XInclude 1.0 – W3C Working Draft 10 Nov 2003 Updated release of the XQuery 1.0, XPath 2.0, Oct 2004 Working draft  Last call working draft  Candidate recommendation  Proposed recommendation  Recommendation Dickson Chiu-2004