Chungnam National University DataBase System Lab. 2014 1 4 2014 1 4 2014 1 4 2014 1 4 2014 1 4 2014 1 4 2014.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

1 Roger L. Costello 16 June 2010 XQuery
Copyright © 1999, Architag International Corporation. All rights reserved. Use without express written permission from Architag International Corporation.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
Transforming XML XMLNamespaces, XSLT. XML Namespaces Sometimes it is necessary to mix XML elements –Different types of content –Use of markup to convey.
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.
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XPath, NameSpaces.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
XML: Extensible Markup Language
XML Craig Stewart Dr. Alexandra I. Cristea
Dr. Alexandra I. Cristea XPath and Namespaces.
Introducing theW3C : Table of Contents 1. What is the W3C 2. The Origin of the W3C 3. The Scope of the W3C 4. W3C Services 5. W3C and XML 6. W3C Documents.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
 2001 Prentice Hall, Inc. All rights reserved. 1.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
4/17/2015Comp Sci 3461 XML_2 Ch. 7. 4/17/2015Comp Sci 3462 XML Vocabularies  MathML  An application to parse, render, and edit MathML: Amaya 
XSLT (eXtensible Stylesheet Language Transformation) 1.
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.
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.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic XML.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
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.
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
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 – Extensible Markup Language XML eXtensible – add to language. Markup – delimit info using tags. Language – a way to express info.
XML Processing Moves Forward XSLT 2.0 and XQuery 1.0 Michael Kay Prague 2005.
Introduction technology XSL. 04/11/2005 Script of the presentation Introduction the XSL The XSL standard Tools for edition of codes XSL Necessary resources.
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://
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Module Road Map Credit Categories Assignment 2 Credit Category 2 You are able to demonstrate how data may be filtered using Xpath You are able to demonstrate.
Lecture 14 Extensible Stylesheet Language Transformations : XSLT.
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 "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lecture 11 XSL Transformations (part 1: Introduction)
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
XML and Database.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
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.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
Martin Kruliš by Martin Kruliš (v1.1)1.
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.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Schema – XSLT Week 8 Web site:
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
XML: Extensible Markup Language
Unit 4 Representing Web Data: XML
XML in Web Technologies
Chapter 7 Representing Web Data: XML
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

Chungnam National University DataBase System Lab Whats New in XSLT 2.0

Chungnam National University DataBase System Lab. Contents XSLT Status XSLT Overview New Feature of XSLT 2.0 Schema Support Grouping Functions Types Regular Expressions Temporary Trees Sequences Character Maps Conclusion References 2

Chungnam National University DataBase System Lab. XSLT Status XSLT 1.0 XSL Transformations (XSLT) Version 1.0 W3C, Published W3C Recommendation : XSLT 2.0 XSL Transformations (XSLT) Version 2.0 W3C, Published W3C Recommendation :

Chungnam National University DataBase System Lab. XSLT Overview A language for transforming XML documents The results can be: Same XML document type with filtered data Another XML document type Other text formats HTML WML Delimited text, etc. XSL contains the languages: XPath: expressions for selecting elements in a document XSLT (XSL Transformations) Other languages e.g. XLink, Xpointer 4

Chungnam National University DataBase System Lab. Features of XPath Identifies particular parts in XML documents Expressions along the tree structure of XML documents Examples: child::chapter Selects all subordinated elements of chapter child::*[self::chapter] Selects all chapter elements of the context element id(´a23´)/child::chapter[position()=5] Selects the fifth child-element with the name chapter of the element with the unified ID a23 5

Chungnam National University DataBase System Lab. Features of XSLT Tree-oriented transformation language based on XML Uses XPath expressions for: Conditional parsing: if / while / test /... Selecting parts of the document: match / select / value-of / template /... Manipulation of strings and numbers Vocabulary for specifying formating: e.g. sorting Variable output formats: e.g. xml, html, plain text,... 6

Chungnam National University DataBase System Lab. XSL Transformation 7 XSLT (eXtensible Stylesheet Language Transformations) Input XML Document Converting Rules: Stylesheet(XSL) XPath XML Document HTML WML Plain Text Output …

Chungnam National University DataBase System Lab. Example of a XSLT 8 Hello XSLT! Hello XSLT!

Chungnam National University DataBase System Lab. Schema Support Grouping Functions Types Regular Expressions Temporary Trees Sequences Character Maps New Feature of XSTL 2.0

Chungnam National University DataBase System Lab. Schema Support Need to import schemas to use: user-defined types substitution groups Import with namespace identifies target namespace schema-location locates schema In order to refer to additional types, you must import the schema that defines them: Must specify at least the namespace or the schema location, if not both 10 <xsl:import-schema namespace=" schema-location="recipes.xsd"/>

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use Well-designed schemas become a useful tool Substitution groups and appropriate types help reduce number of templates Check whether the result conforms to the schema while generating it 11

Chungnam National University DataBase System Lab. Grouping XSLT 1.0 allowed sorting, but not SQL-style grouping XSLT 2.0 provides a new, flexible grouping instruction for grouping iterates through a set of groups. Attributes: select: XPath expression for which elements to select group-by: Node by which to group the results group-adjacent: Leaves elements in their original order and groups elements with the same key value together group-starting-with: Specifies a node that will be treated as the beginning of a new group group-ending-with: Specifies a node that will be treated as the end of the group 12

Chungnam National University DataBase System Lab. Grouping Functions to know: current-grouping-key() returns the current value of the grouping key shared by members of the group current-group() returns a reference to the current group Grouping by key(Example) 13 <xsl:for-each-group select="cities/city" <xsl:value-of separator=", "/> 1 Italia Milano, Venezia 2 France Paris, Lyon

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use Much easier to convert from flat to hierarchical structures Processing XHTML to DocBook (or XHTML 2.0) Easier to create indexes Easier to create summaries/roll-ups Easier to create paginated documents 14

Chungnam National University DataBase System Lab. Functions XSLT is really a programming language, but in version 1.0 lacked the ability to define new functions XSLT 2.0 rectifies this: You can define new functions These functions can take 0 or more parameters These functions can return a value 15

Chungnam National University DataBase System Lab. Functions … wraps the function. Attributes: name: The name of the function as: Data type returned by the function (as an XML Schema data type) override: Whether this function should override previous definitions with the same name and arity (number of xsl:param elements in the function definition) Content of the function: 0 or more elements that define incoming parameters Code to execute – final value can be returned via,, or another expression 16

Chungnam National University DataBase System Lab. Function Example 17 <xsl:sequence select= if (contains($sentence, ' ')) then concat(str:reverse( substring-after($sentence, ' ')), ' ', substring-before($sentence, ' ')) else $sentence"/> <xsl:sequence select="str:reverse(Database System')" />

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use General replacement for named templates Particular use where XSLT code can't be used: creating a value to sort by using creating a value to index by using creating a value to group by using carrying out complex tests on nodes, for use in match patterns in templates or keys 18...

Chungnam National University DataBase System Lab. Types Strong Typing in XSLT 2.0 The type of a sort key determines how values are sorted If the wrong type of value is passed as a parameter to a template, you will get an error XSLT 2.0 allows you to declare: The type of variables The return type of templates The type of sequences (constructed with xsl:sequence) The return type of (user-declared) functions Both the type and required type of parameters 19

Chungnam National University DataBase System Lab. Declaring Types of Variables Declare the type of variables and parameters with as attribute 20 is the integer value 1 is the double value 1.0 is the string is the date November 20, 2003 is an error

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use Easy to get errors from a stylesheet unless you're rigorous in keeping track of types Declare types of variables and parameters Cast elements/attributes to particular types 21

Chungnam National University DataBase System Lab. Regular Expressions Within XSLT 2.0, there are three key functions that use regular expressions: Tokenize(string, regex, flags?): Lets you split a string into pieces at each point where a delimiter or pattern occurs matches(string, regex, flags?): Returns a boolean with whether the string in the first argument contains the pattern in the second argument Replace(string, regex, replacement, flags?): Replaces the string or pattern in the first argument with the string in the second argument 22

Chungnam National University DataBase System Lab. Regular Expression Instructions XSLT 2.0 has instruction Uses regular expressions to apply markup to a string select attribute selects string regex The pattern to which the string is compared string split into a sequence of matching and non-matching substrings processed in turn by: for matching for non-matching 23

Chungnam National University DataBase System Lab. Example String Analysis 24 Mary had a little lamb, Its fleece was white as snow; And everywhere that Mary went The lamb was sure to go. Mary had a little lamb, Its fleece was white as snow; And everywhere that Mary went The lamb was sure to go.

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use Potential to process any text format comma-delimited and fixed-format files CSS files C#, Java code? These are hard because of matching tags/braces Addition of regular expressions and XSD type support, it now becomes possible for an XSLT 2.0 transformer to read something like a Java or C# header Possible to parse non-comformant HTML files and convert them into valid XHTML. 25

Chungnam National University DataBase System Lab. Transclusion Transclusion is the act of dynamically including data from another resource into the current resource Sample code using the document() function: 26 doc1.xml First paragraph Last paragraph

Chungnam National University DataBase System Lab. Temporary Trees XSLT 1.0 had Result Tree Fragments Result trees are read-only. Created when use content of Tree that couldn't be accessed with location path Most processors have xxx:node-set() extension function Convert result tree fragment to node tree In XSLT 2.0, have temporary trees Can copy in same way as RTFs Can access without using extension function Provides a instruction to create multiple result documents Provides support for validation 27

Chungnam National University DataBase System Lab. Example Temporary Tress <xsl:value-of select="exsl:node-set($menus)/menu = /> <xsl:value-of select="$menus/menu = /> XSLT 1.0 XSLT 2.0

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use Break up complex transformations into several steps Filter, sort, annotate nodes in early steps Later steps are easier to write Create lookup tables Translate from codes or numbers to labels Similar to arrays or matrices Iteratively process a document until it fulfils some test Add content until a document is valid 29

Chungnam National University DataBase System Lab. Sequences Every sequence of instructions creates a sequence of items When a sequence is added to a node: Atomic values are converted to text nodes Spaces added between atomic values Nodes are copied to create children 30 sequence of any items sequence of new n odes children of node

Chungnam National University DataBase System Lab. Sequences The instruction is used to construct sequences of nodes or atomic values (or both) Adds existing nodes or new atomic values to a sequence returns a sequence of integers. returns a sequence of doubles. 31

Chungnam National University DataBase System Lab. Using Sequences in XSLT 2.0 Iterate over a sequence Create a text node from a sequence 32 <xsl:value-of select="author/surname" separator=", " /> Thompson, Tobin

Chungnam National University DataBase System Lab. Implications for XSLT 2.0 Use Less need for recursive templates Use integer sequences to iterate a number of times Use to build node sequences by iteration rather than recursion Less need for temporary elements Atomic values don't need to be wrapped in an element in order to be passed around in a list 33

Chungnam National University DataBase System Lab. Character Maps Character maps give you greater control over serialization. They map a Unicode character to any string in the serialized document For XML and HTML output methods, the resulting character stream does not have to be well-formed The mapping occurs only at serialization: it is not present in result tree fragments This facility can be used instead of disabled output escaping in most cases 34

Chungnam National University DataBase System Lab. Conclusion XSLT 2.0 introduces a lot of new features Many stylesheets can be simpler: multi-step processing with temporary trees Grouping using user-defined functions for repetitive code Stylesheet applications can be simpler: Multiple result documents should reduce need for client-side scripting XSLT 2.0 expands into text parsing Using schemas/types well will make things easier; not using them will make things harder 35

Chungnam National University DataBase System Lab. References W3C, XSL Transformations (XSLT) Version , 16, November. 1999http:// W3C, XSL Transformations (XSLT) Version /, 12, January. 2007http:// / Steve Heckler, XSLT20.ppt, Accelebrate Kurt Cagle, Reevaluating XSLT 2.0, 9, March