1 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 Advanced Database SystemsCOSC282 G OWRI S HANKAR D ARA T EAM M EMBERS D ARREL M AZZARI A LBIN L AGA A DITYA T.

Slides:



Advertisements
Similar presentations
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Advertisements

XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
XML: Extensible Markup Language
1 RDF Tutorial. C. Abela RDF Tutorial2 What is RDF? RDF stands for Resource Description Framework It is used for describing resources on the web Makes.
RDF Tutorial.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
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?
The learning site: /xpath_syntax.asp xsl/xsl/slides.html.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
1 Introduction to XML. XML eXtensible implies that users define tag content Markup implies it is a coded document Language implies it is a metalanguage.
1 COS 425: Database and Information Management Systems XML and information exchange.
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
XSLT transformations Or how to get your XML to become HMTL.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introduction to XML Rashmi Kukanur. XML XML stands for Extensible Markup Language XML was designed to carry data XML and HTML designed with different.
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,
Introduce of XML Xiaoling Song CS157A. What is XML? XML stands for EXtensible Markup Language XML stands for EXtensible Markup Language XML is a markup.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
SD2520 Databases using XML and JQuery
XSLT XSLT: eXtensible Stylesheet Language for Transformations - a language for transforming XML documents into any text- based format (e.g. HTML, plain.
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.
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.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
XML Processing Moves Forward XSLT 2.0 and XQuery 1.0 Michael Kay Prague 2005.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
Comparing XSLT and XQuery Michael Kay XTech 2005.
XSLT transformations Or how to get your XML to become HMTL.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
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.
Another PillowTalk Presentation  2004 Dynamic Systems, Inc. Introduction to XML for SOA Lee H. Burstein,
An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.
Session II Chapter 2 – Chapter 2 – XSLhttp://
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
INTERPRETING IMPERATIVE PROGRAMMING LAGUAGES IN EXTENSIBLE STYLESHEET LANGUAGE TRANSFORMATIONS (XSLT) Authors: Ruhsan Onder Assoc.
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
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.
CIS 375—Web App Dev II XSL. 2 XSL Introduction XSL stands for _____________________________. XSL is the language used for manipulating and displaying.
Lecture 11 XSL Transformations (part 1: Introduction)
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
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.
Sheet 1 DocEng’03, Grenoble, November 2003 Model Driven Architecture based XML Processing Ivan Kurtev, Klaas van den Berg University of Twente, the Netherlands.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
XML Presented by Kushan Athukorala. 2 Agenda XML Overview Entity References Elements vs. Atributes XML Validation DTD XML Schema Linking XML and CSS XSLT.
1 Typing XQuery WANG Zhen (Selina) Something about the Internship Group Name: PROTHEO, Inria, France Research: Rewriting and strategies, Constraints,
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Introduction XML stands for eXtensible Markup Language. Designed to transport and store data; not to display it XML is similar to HTML, but tags are not.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
XML and Distributed Applications By Quddus Chong Presentation for CS551 – Fall 2001.
XML 1. Chapter 8 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE XML SCHEMA (XSD) 2 Schema is a record definition, analogous to the.
XML: Extensible Markup Language
Querying and Transforming XML Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Extensible Markup Language XML
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Chapter X IXXXXXXXXXXXXXXXX.
More XML XML schema, XPATH, XSLT
Presentation transcript:

1 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 Advanced Database SystemsCOSC282 G OWRI S HANKAR D ARA T EAM M EMBERS D ARREL M AZZARI A LBIN L AGA A DITYA T RIPURANENI

2 OVERVIEW INTRODUCTION SYSTEM ARCHITECTURE APPROACH SPECIFIC EXAMPLES CONCLUSION T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

3 WHY USE XSLT & XQUERY 1.) Overcome most technical heterogeneities of diverse databases by using W3C recommendations XPath and XQuery, and other techniques like XSLT and SOAP (Simple Object Access Protocol) 2.) XML databases can be transmitted and stored as text files with schema information transported using XML schemas or Document Type Definition files. 3) XSLT is written independently of any programming language and it can be executed by a program written in most modern programming languages (Jovanovic, et. al., 2005).

4 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 Definitions XML (eXtensible Markup Language) is a standard for creating markup languages which describe the structure of data. XSLT (eXtensible Stylesheet Language Transformations) is the language used in XSL style sheets to transform XML documents into other XML documents, on the basis of a set of well-defined rules.

5 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 Definitions Xquery is a programming language that provides a mechanism to extract and manipulate data from XML documents or any data source that can be viewed as XML. Xpath is a language that describes how to locate specific elements (and attributes, processing instructions, etc.) in a document. FLWR (For, Let, Where, & Result) is the SQL statement equivalents for Xquery to process and restructure data from one or more documents.

6 FUNCTIONAL COMPARISON T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

7 XSLT DOCUMENT 0 XQUERY JAVA APPLICATION XSLTXSLT XPath 2.0 XQueryXQuery

8 APPROACH Both XSLT and XQuery share XPath2.0 as a subset XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document. XPath is a syntax for defining parts of an XML document XPath uses path expressions to navigate in XML documents XPath contains a library of standard functions T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

9 APPROACH SYNTAX DIFFERENCES Syntactical Style of the two languages. xquery version 1.0; declare function local:copy($node as element()){ element {node-name($node)} { for $c in child::node return typeswitch($c) case $e as element() return local:copy($a) case $t as text() return $t case $c as comment() return $c case $p as processing-instruction return $p } }; T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

10 APPROACH FLWOR EXPRESSIONS XQuery ConstructXSLT equivalent for $var in SEQ let $var := SEQ where CONDITION order by $X/VALUE T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

11 APPROACH Template based approach and User-defined functions Template-based approach of XSLT can be implemented using XQuery user-defined functions.  Xquery variables are used to model the XSLT context.  Relative XPath expressions are translated into equivalent absolute expressions. Context and relative path expressions XSLT : count(cd/price) XQuery: count(var_t2q/cd/price) T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

12 Empire Burlesque Bob Dylan USA Columbia Hide your heart Bonnie Tyler UK CBS Records Greatest Hits Dolly Parton USA RCA APPROACH T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

13 APPROACH The notion of match pattern does not exist in Xquery.  Match patterns are translated into equivalent XPath expressions by reversing the pattern. Match patterns XSLT : CD/Title[2]/Artist XQuery: parent_node()/Title[2]/Artist T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

14 Empire Burlesque Bob Dylan USA Columbia Hide your heart Bonnie Tyler UK CBS Records Greatest Hits Dolly Parton USA RCA APPROACH Match patterns T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

15 APPROACH Templates are translated into equivalent Xquery user defined functions. Templates void t2q_template(Node t2q_node, int t2q_pos, int t2q_size, String t2q mode){ } T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

16 Empire Burlesque Bob Dylan USA Columbia Hide your heart Bonnie Tyler UK CBS Records Greatest Hits Dolly Parton USA RCA cdcatalog.xml GROUPING T RANSFORMING XSLT 2.0 T O XQ UERY 1.0

17 XSLT version 1.0 (The Muenchian Method developed by Steve Muench.) Key element is use to declares a set of keys Function: node-set key('by-country', country) Key function returns a set of nodes Function: string generate-id(node-set?) XSLT version 2.0 xsl:sort T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 GROUPING

18 Population, the sequence of items to be grouped. Grouping keys XSLT version 2.0 <xsl:for-each-group select = expression group-by? = expression group-adjacent? = expression group-starting-with? = pattern group-ending-with? = pattern collation? = { uri } > xsl:sort Assignment to the group depends on these attributes. Only one of these parameters can be specified at any time! T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 GROUPING

19 XSLT version Example CD# = T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 GROUPING

20 XQuery version 1.0 declare function local:cd-info($cd as element()? ) as element()? { let $t := $cd/title let $a := $cd/artist return Title: {data($t)} Artist: {data($a)} }; for $c in distinct-values(doc("cdcatalog.xml")/catalog/cd/country) return {$c} { for $x in doc("cdcatalog.xml")/catalog/cd where $x/country = $c return {local:cd-info($x)} } CD# = {count(doc("cdcatalog.xml")/catalog/cd[country=$c])} T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 GROUPING

21 XSLTXQuery T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 GROUPING

22 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 COUPLING BETWEEN XSLT AND XQUERY Even if the languages targets two different user communities, modern applications will increasingly require expertise in both. Ex: Joins are very naturally expressed using XQuery’s “FLWOR” expressions, while XML to HTML conversion is still often easier to write using XSLT’s template-based approach. Popular systems support only one of these two languages, but not the other. Ex: All popular database management systems are planning to support XQuery, but not always XSLT, while some popular editors and libraries support XSLT but not XQuery. For all those reasons, there is a strong need to develop technology which can provide a tight coupling between these two. Reasons

23 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 Technical Aspects For some rules we provided detailed compilation for transforming the template based approach of XSLT 2.0 into XQuery’s functional approach. The rules are designed in order to provide the most Natural compilation, so that the resulting program can easily be understood by an experienced XQuery programmer. Covering the complete XSLT language is difficult due to its size and complexity. We identify the fragments of the language that are the most challenging to compile into XQuery, and provide some corresponding solutions. We describe the architecture of that prototype we intend to build and provided examples which demonstrate the feasibility of the approach.

24 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 COMPARISON OF XSLT AND TRANSFORMED XQUERY

25 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 KNOWLEDGE GAINED XPATH 2.0 XSLT 2.0 XQUERY 1.0 DOM PARSER

26 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 References Köhler J (2004), Integration of life science databases, Drug Discovery Today: BIOSILICO, Volume 2, Issue 2, 1 March, Pages Jovanovic J, Gasevic D (2005), Achieving knowledge interoperability: An XML/XSLT approach, Expert Systems with Applications, Volume 29, Issue 3, October 2005, Pages Kay, M. (2005). Comparing XSLT and XQuery. Proceedings of the XTech 2005 Conference on XML, the Web and beyondComparing XSLT and XQuery. Eisenberg, J. D. (2005). Comparing XSLT and XQuery, last accessed on December 2, 2005 from XSLT Tutorial XQuery Tutorial Achille Fokoue, Kristoffer Rose et. Al (2005) Compiling XSLT 2.0 into XQuery 1.0, ACM 9/05/