Comparing XSLT and XQuery Michael Kay XTech 2005.

Slides:



Advertisements
Similar presentations
Chungnam National University DataBase System Lab
Advertisements

Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
Multimedia Seminar XSLT Tobias Naumann. MM Seminar - XSLT2 Structure What is XSLT? Design and Concepts Practical use Examples.
XML: Extensible Markup Language
Internet Technologies1 1 Lecture 4: Programming with XSLT.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSL XSLT and XPath 11-Apr-17.
Jennifer Widom Querying XML XSLT. Jennifer Widom XSLT Querying XML Not nearly as mature as Querying Relational  Newer  No underlying algebra Sequence.
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. 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.
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
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.
XSLT eXtensible Stylesheet Language Transformations Naveed Arshad.
DSA Semester 2. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
Processing XML Processing XML using XSLT Processing XML documents with Java (DOM) Next week -- Processing XML documents with Java (SAX)
Transforming XML The XSLT Language Michael H. Kay.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
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.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Internet Technologies XSLT Processing XML using XSLT Using XPath Escaping to Java.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Internet Technologies1 XSLT Processing XML using XSLT Using XPath.
17 Apr 2002 XML Stylesheets Andy Clark. What Is It? Extensible Stylesheet Language (XSL) Language for document transformation – Transformation (XSLT)
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
JSP Standard Tag Library
XML Processing Moves Forward XSLT 2.0 and XQuery 1.0 Michael Kay Prague 2005.
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.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
WORKING WITH XSLT AND XPATH
Session II Chapter 2 – Chapter 2 – XSLhttp://
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Implementing Forms and Form Renderers in the Open Source Portfolio David McPherson, Chris Maurer Will Trillich, Janice Smith Materials by Sean Keesler.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
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.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT.
XSLT I Robin Burke ECT 360. Outline XSLT processing XSLT syntax XPath XSLT basics Lab.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
XML eXtensible Markup Language. Topics  What is XML  An XML example  Why is XML important  XML introduction  XML applications  XML support CSEB.
Optimization in XSLT and XQuery Michael Kay. 2 Challenges XSLT/XQuery are high-level declarative languages: performance depends on good optimization Performance.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
XQuery Leah Andrews. Overview  Queries data stored in XML trees  Declarative  High-level  Functional (no side effects)  Strongly typed  Nodes 
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
Martin Kruliš by Martin Kruliš (v1.1)1.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
XSLT I Robin Burke ECT 360. Outline History / Terminology XSLT processing XSLT syntax XPath XSLT basics Lab.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
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.
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
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.
Unit 4 Representing Web Data: XML
Querying and Transforming XML Data
XML in Web Technologies
Querying XML XQuery.
Querying XML XQuery.
Querying XML XSLT.
Presentation transcript:

Comparing XSLT and XQuery Michael Kay XTech 2005

2 About me Database background Started using XML in 1998 for content management applications Author of XSLT Programmer’s Reference Developer of Saxon XSLT processor Member of W3C XSL and XQuery Working Groups Founded SAXONICA March 2004

3 Comparison Points 1: Functionality –features in the language 2: Aesthetics –likes and dislikes –learning barriers –usability, actual and perceived 3: Implementations –maturity, conformance –performance –market focus

4 Functional Overlap Same data model and type system XPath as common subset Same function library Similar mechanisms for defining functions Similar mechanisms for constructing elements and attributes Both declarative languages

5 XSLT 2.0 also has... Template rules Formatting (dates, numbers) More regular expression handling Multiple output documents Plain text input and output Refinement (import precedence) Keys

6 XQuery FLWOR expressions Relational style of query Convenient for data manipulation Optimization theory well-understood Appeal to SQL users No functionality that can’t be expressed in XSLT

7 Consequences... XSLT is stronger on –rendition –up-conversion –documents XQuery is stronger on –optimization –structured data

8 Use of XML Syntax XSLT uses XML syntax, XQuery doesn’t Advantages: –stylesheets are documents, they can be edited, stored, transformed, validated, embedded, transcoded –XML syntax is extensible and robust Disadvantages: –XML is ugly and verbose –Easier to embed XQuery in Java or C#

9 XSLT Example 1 remove attributes <xsl:stylesheet version=“2.0" xmlns:xsl=" ">

10 XQuery Example 1 remove attributes 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 } }; local:copy(/*)

11 XQuery Example 2 join two tables xquery version 1.0; { for $p in doc ("auction.xml")/site/people/person let $a := for $t in doc("auction.xml") /site/closed_auctions/closed_auction where = return $t return {count ($a)} } XMark Q8

12 XSLT Example 2 join two tables <xsl:variable name="a" select="/site/closed_auctions/closed_auction = XMark Q8

13 XSLT Learning Barriers XML: –encoding, entities, whitespace, namespaces Declarative programming: –variables, recursion, paths, grouping Data model –nodes not angle brackets Rule-based programming –templates

14 XQuery Learning Barriers XML: –encoding, entities, whitespace, namespaces Declarative programming: –variables, recursion, paths, grouping Data model –nodes not angle brackets Rule-based programming –templates

15 Learning Barriers? It depends where you are coming from! Many XQuery users come from SQL –less trouble with set algebra –tend to write everything as a FLWOR expression let $x := //item where $x/code = 3 return $x spot the error!

16 Performance and Optimization XMark Q8 (shown earlier) –XQuery version –XSLT version Database sizes –1Mb –4Mb –10Mb

17 XMark Q8 results (msecs) 1Mb Xalan xt MSXML Saxon 8.4 XSLT XQuery Saxon 8.4 Qizx Galax Mb Mb O(n 2 ) O(n)

18 Two can play at that game! Xalan xt MSXML Saxon 8.5 1Mb XSLT XQuery Saxon 8.5 Qizx Galax Mb Mb O(n 2 ) O(n) caveat: this is one query only!

19 Conclusions Two languages with a high degree of functional overlap Different aesthetics, but similar learning challenges XSLT has richer functionality especially for document rendering XQuery products are more likely to be optimized for large amounts of structured data