XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.

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

XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
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. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
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.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
XSLT (eXtensible Stylesheet Language Transformation) 1.
Introduction to XSLT. What is XML? Design Goals of XML XML Format XML Declaration ElementsAttributes.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
XSL Transformations (XSLT) Meghasyam Bokam April’1 st, 2002.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
XSL Unit 6 November 2. XSL –eXtensible Stylesheet Language –Basically a stylesheet for XML documents XSL has three parts: –XSLT –XPath –XSL-FO.
A note on generating text with the xsl:value-of instruction.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
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.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
More on XSLT. More on XSLT variables Earlier we saw two ways to associate a value with a variable  A variable whose value is the empty string, for example.
XSLT XSLT: eXtensible Stylesheet Language for Transformations - a language for transforming XML documents into any text- based format (e.g. HTML, plain.
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.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
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.
CSE3201/CSE4500 Information Retrieval Systems
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XSLT and XPath, by Dr. Khalil1 XSL, XSLT and XPath Dr. Awad Khalil Computer Science Department AUC.
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
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
XPath Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
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)
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method.
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.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
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.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
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.
1 XMLXSL(T) and CSS NOEA/PQC (rev. fen) 2007 Stylesheets CSS:Cascading Style Sheets XSL(T):eXtended Stylesheet Language (Transformations)
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
XML Introduction to XML Extensible Markup Language.
XML Schema – XSLT Week 8 Web site:
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
CH 15 XSL Transformations 1. Objective What is XSL? Overview of XSL transformations Understanding XSL templates Computing the value of a node with xsl:value-of.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
XSLT: The XML transformation language
Applying eXtensible Style Sheets (XSL)
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
Presentation transcript:

XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University

168493: XML and Web Services (II/2546) 2 XSL - The Style Sheet of XML XML does not use predefined tags (we can use any tags we want) could mean an HTML table, a piece of furniture, or something else XSL: something in addition to the XML document that describes how the document should be displayed

168493: XML and Web Services (II/2546) 3 What is XSLT? XSLT transforms an XML document into another XML document, such as an XHTML document XSLT can Add new elements into the output file Remove elements Rearrange and sort elements Test and make decisions about which elements to display

168493: XML and Web Services (II/2546) 4 How Does XSLT Work? XSLT transforms an XML source tree into an XML result tree XSLT uses XPath to define parts of the source document that match one or more predefined templates

168493: XML and Web Services (II/2546) 5 How Does XSLT Work? When a match is found, XSLT will transform the matching part of the source document into the result document The parts of the source document that do not match a template will end up unmodified in the result document

168493: XML and Web Services (II/2546) 6 Style Sheet Declaration The root element that declares the document to be an XSL sheet is or The correct way to declare an XSL style sheet according to the W3C XSL Recommendation is: <xsl:stylesheet version=“1.0”? xmlns:xsl=“ ansform”> ansform

168493: XML and Web Services (II/2546) 7 XSL Uses Templates An XSL style sheet consists of a set of rules called templates Each element contains rules to apply when a specified node is matched The match attribute is used to associate the template with a set of XML elements

168493: XML and Web Services (II/2546) 8 XSL Uses Templates (Cont.) The match attribute can also be used to define a template for a whole branch of the XML document Match = “/” defines the whole document What is another way to select the entire document? An XSL processor parses an XML source and tries to find a matching template rule. If it does, instructions inside matching template are evaluated

168493: XML and Web Services (II/2546) 9 Sample XSL File <xsl:stylesheet version="1.0" xmlns:xsl=" XSL/Transform"> My CD Collection Title Artist

168493: XML and Web Services (II/2546) 10 The first lines of the XSL file Since the style sheet is an XML document itself, the document begins with an XML declaration The tag defines the start of the style sheet Every XSL file needs to specify the XSL namespace so that the parser knows which version of XSLT to use

168493: XML and Web Services (II/2546) 11 Namespace in XSL The namespace prefix xsl: is used in the rest of the XSL file to identify XSL processing statements If a statement is not prefixed with xsl:, then it’s simply copied to the output without being processed. This is the way to add HTML statements to the output

168493: XML and Web Services (II/2546) 12 The Element Before processing can begin, the part of the XML document with the transformation must be selected with an XPath expression The selected section of the document is called a node and is normally selected with the match operator

168493: XML and Web Services (II/2546) 13 The Element The element extracts the value of a selected node Example: Result: Hide your heart

168493: XML and Web Services (II/2546) 14 The Element The element allows you to do looping in XSL It selects every XML element of a specified node set Selects every ‘catalog/cd’ element

168493: XML and Web Services (II/2546) 15 Filtering the Output We can filter the output from an XML file by adding a criterion to the select attribute in the element

168493: XML and Web Services (II/2546) 16 The Element The element is used to sort the output To output the XML file as an XHTML file, and sort it at the same time, simply add a sort element inside the for-each element in the XSL file

168493: XML and Web Services (II/2546) 17 The Element The select attribute indicates what XML elements to sort on

168493: XML and Web Services (II/2546) 18 The Element The element contains a template that will be applied only if a specified condition is true some output … The value of the required test attribute contains the expression to be evaluated

168493: XML and Web Services (II/2546) 19 The Element The element is used in conjunction with and to express multiple conditional tests If no element is true, and no element is present, nothing is created

168493: XML and Web Services (II/2546) 20 The Element

168493: XML and Web Services (II/2546) 21 The Element The element applies a template rule to the current element or to the current element’s child nodes The element is always found inside a template body

168493: XML and Web Services (II/2546) 22 (Cont.)

168493: XML and Web Services (II/2546) 23 The : An instruction to apply templates to the children of the current nodes My CD Collection …

168493: XML and Web Services (II/2546) 24 The Element The element allows an element to be created with a computed name It generates elements in time of processing

168493: XML and Web Services (II/2546) 25 The Element The element can be used to add attributes to result elements whether created by Literal result elements in the style or Instructions such as xsl:element center

168493: XML and Web Services (II/2546) 26 The Element The element provides an easy way of copying the current node The namespace nodes of the current node are automatically copied It may have a use-attribute-set attribute to specify and also copy attributes for copied element

168493: XML and Web Services (II/2546) 27 (Cont.) Example Greeting

168493: XML and Web Services (II/2546) 28 The element The xsl:copy-of element can be used to insert a result tree fragment into the result tree, without first converting it to string as xsl:value-of does But when the result is neither a node-set nor a result tree fragment, the result is converted to a string and then inserted into the result tree

168493: XML and Web Services (II/2546) 29 The Element XML: Hello Output: Hello

168493: XML and Web Services (II/2546) 30 The Element The element allows stylesheet authors to specify how they wish the result tree to be output If an XSLT processor outputs the result tree, it should do so as specified by the element However, it is not required to do so

168493: XML and Web Services (II/2546) 31 The Element xsl:stylesheetversionxsl:outputmethodxsl:templatematchxsl:copy-ofselectxsl:templatexsl:stylesheet

168493: XML and Web Services (II/2546) 32 The Element XML source Output (in HTML)

168493: XML and Web Services (II/2546) 33 The Element xsl:stylesheetversionxsl:outputmethodxsl:templatematchxsl:copy-ofselectxsl:templatexsl:stylesheet

168493: XML and Web Services (II/2546) 34 The Element XML source Output (in XML)

168493: XML and Web Services (II/2546) 35 The Element The element is used to insert a formatted number into the result tree The number to be inserted may be specified by an expression The value attribute contains an expression If no value attribute is specified, the xsl:number element inserts a number based on the position of the current node

168493: XML and Web Services (II/2546) 36 (Cont.) Output: <xsl:number value=“250000” grouping-size=“2”/> Output: 25,00,00

168493: XML and Web Services (II/2546) 37 The Element Literal data characters may be wrapped in an element This wrapping may change what whitespace characters are stripped but does not affect how the characters are handled by the XSLT processor

168493: XML and Web Services (II/2546) 38 The Element XML source Output

168493: XML and Web Services (II/2546) 39 The Element The specify a variable which is a name that may be bound to a value The value to which a variable is bound (the value of the variable) can be an object of any of the types that can be returned by expressions

168493: XML and Web Services (II/2546) 40 The Element Both and are used to bind variables But the value specified on the variable is only a default value for the binding The value specified on the can be changed later