XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.

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

Advanced XSLT. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
 2001 Prentice Hall, Inc. All rights reserved. 1.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XML and XSL Transforming your XML documents with eXtensible Stylesheet Language Transformations [Optional Lecture]
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
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.
XSL Transformations Lecture 8, 07/08/02. Templates The whole element is a template The match pattern determines where this template applies Result element(s)
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.
Cornell CS 502 More XML XML schema, XPATH, XSLT CS 502 – Carl Lagoze – Cornell University.
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.
SD2520 Databases using XML and JQuery
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.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
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.
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.
CIS 451: XSL Dr. Ralph Westfall February, Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used.
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,
Transforming XML Part II XML Document Transformation with XSLT John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
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 "
XSLT I Robin Burke ECT 360. Outline XSLT processing XSLT syntax XPath XSLT basics Lab.
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
ITB Web programming for E- Commerce 1 ITB6227 Programming for E-COMMERCE Lecture Presentation of XML Documents.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
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.
CSE3201/CSE4500 Information Retrieval Systems XSLT – Part 2.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
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.
XML Schema – XSLT Week 8 Web site:
Some Notes on XSLT Eugenia Fernandez IUPUI. Transforming XML with XSLT XSLT processor converts XML document into a node tree Uses XSLT stylesheet for.
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:
Using XSLT and XPath to Transform XML Documents
XML Data Introduction, Well-formed XML.
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
Attributes, Empty-Element Tags, and XSL
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended to be used as a tutorial on XML and related technologies Slide author: Jürgen Mangler This section contains examples on: XSLT (eXtensible Stylesheet Language - Transformations)

With XSL you can freely modify the content and/or layout any source text. You can apply different Stylesheets to the same source to get different results. XSL John Smith Output: John Smith XSL How can you produce the following output? John Smith XSL

Every XSL stylesheet must start with an xsl:stylesheet element. The attribute version='1.0' specifies version of XSL(T) specification. This example shows the simplest possible stylesheet. As it does not contain any information, default processing is used. Hello, world Output: Hello, world

An XSL processor parses an XML source and tries to find a matching template rule. If it does, instructions inside the matching template are evaluated. Hello, world. I am fine. Output Hello, world. I am fine.

Contents of the original elements can be recovered from the original sources in two basic ways. Stylesheet 1 uses xsl:value-of construct. In this case the contents of the element is used without any further processing. The instruction xsl:apply-templates in Stylesheet 2 is different. The parser further processes selected elements, for which a template is defined. Joe Smith For the next page we use this source

Stylesheet 1: Stylesheet 2: Joe Smith Which Stylesheet produces which Output?

Parts of an XML document to which a template should be applied are determined by location paths. The required syntax is specified in the XPath specification. Simple cases looks very similar to filesystem addressing. id= Output DDD id=d1

Processing always starts with the template match="/". This matches the root node (the node whose only child element is the document element, in our case "source"). Many stylesheets do not contain this element explicitly. When this template is not explicitly given, the implicit template is used (it contains as the sole instruction). This instruction means: process all children of the current node, including text nodes.

id= id= Output AAA id=a1 AAA id=a2 Parses only first level under

id= Output AAA id=a1 BBB id=b1 BBB id=b2 AAA id=a2 BBB id=b3 BBB id=b4 Recurses into sublevels of

A template can match individual paths being separated with "|" ( Stylesheet 1) from a selection of location paths. Wildcard "*" selects all possibilities. Compare Stylesheet 1 with Stylesheet 2. Stylesheet 1: [template: outputs ] Joe Smith Output: [template: firstName outputs Joe ] [template: surname outputs Smith ]

A template can match individual paths being separated with "|" ( Stylesheet 1) from a selection of location paths. Wildcard "*" selects all possibilities. Compare Stylesheet 1 with Stylesheet 2. Stylesheet 2: [template: outputs ] Joe Smith Output: [template: source outputs [template: employee outputs [template: firstName outputs Joe ] [template: surname outputs Smith ] ] ]

With modes an element can be processed multiple times, each time producing a different result. Stylesheet 2: Output: CCC CCC CCC CCC CCC CCC

Axes play a very important role in XSLT – e.g. child axis, for-each. Stylesheet 2: : Document: Output: a2: b4 c1

xsl:element generates elements in time of processing. In this example it transforms the sizes to formating tags. Header1 Header3 Bold text Subscript Superscript Output: Header1 Header3 Bold text Subscript Superscript

xsl:if instruction enables conditional processing. A typical case of xsl:for-each usage is to add a text between individual entries. Very often you do not want to add text after the last element:, Output: A, B, C, D

Numbering of individual chapter elements depends on the position of the chapter element. Each level of chapters is numbered independently. Setting the attribute level to multiple enables natural numbering. - First Chap. Sec. Chap. Sub 1 Sub 2 What could be the possible output? Continued on next page.

Numbering of individual chapter elements depends on the position of the chapter element. Each level of chapters is numbered independently. Setting the attribute level to multiple enables natural numbering. Output: 1 - First Chap. 2 - Sec. Chap Sub Sub 2

You can set variables in a Stylesheet and use them later in the processing. The following example demonstrates a way of setting xsl:variable. / xsl:for-eachxsl:template Chapter Chapter Chapter Chapter What could be the possible output? Continued on next page.

You can set variables in a Stylesheet an use them later in the processing. The following example demonstrates a way of setting xsl:variable. Output: Chapter 1/4 Chapter 2/4 Chapter 3/4 Chapter 4/4