Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.

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.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSLT (eXtensible Stylesheet Language Transformation) 1.
XSL XSLT and XPath 11-Apr-17.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
XML Name spaces. Different people may invent similar tag names Here is an XML element describing a piece of furniture: table99 dining table Here.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
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.
XHTML. XHTML is one of the many XML-based languages that have been defined XHTML is, essentially, a “cleaned-up” version of HTML 4, reformulated using.
Valid XML documents To be valid, an XML document –must be well-formed according to the general XML syntax rules –and, in addition, it must satisfy the.
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.
Lecture 12. Default Processing in XSLT The default processing in XSLT is to process the XPath root node The default processing for various node types.
CS 4408 Lecture 9. XSLT instruction elements We have seen that a template can contain non-XSLT text, canned text that it inserts into the result tree.
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
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.
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.
XSLT 1. C ONTENTS XSLT and uses XSLT example Simple XML How XSLT works? Template-match Value-of For-each and sort If Choose-when Apply-templates Where.
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.
SDPL 20075: Overview of XSLT1 5 Document Transformations n XSLT (1.0 W3C Rec. 11/1999; XSLT 2.0 Rec. 1/07) –A language for transforming XML documents –initial.
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.
XSL XML Stylesheet Langauage. XPath Notation for addressing elements in an XML document /xyz - selects the root element /xyz/abc - selects all elements.
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
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.
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.
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.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
XSLT Introduction. XSLT is the transformation part of XSL An XSLT file contains rules which are applied against and XML file to produce an output Outputs.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
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.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
IT Accessibility Committee XML as Content Management Presented by Michael B. Short May 11, 2006 Prepared by the NYS Forum IT Accessibility Committee
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
1 XMLXSL(T) and CSS NOEA/PQC (rev. fen) 2007 Stylesheets CSS:Cascading Style Sheets XSL(T):eXtended Stylesheet Language (Transformations)
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:
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.
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.
Module Road Map Document Transformations Web Form (ASPX) HTML Form.
In this session, you will learn to:
Displaying XML Data with XSLT
XSLT 1.0.
Applying eXtensible Style Sheets (XSL)
More Sample XML By Sadia Anjum.
XSL XSLT and XPath 24-Feb-19.
XSL XSLT and XPath.
Unit 6 - XML Transformations
Presentation transcript:

Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables arbitrary ways of rendering XML documents –XSL enables an XML document to be translated into any arbitrary format, including, say, PDF or HTML Server-side software, driven by XSL stylesheets, can transform XML documents into HTML documents before serving them to browsers In addition, modern browsers, such as Firefox or MSIE 5.5 or later, can accept XSL stylesheets We will consider browser-processed XSL stylesheets first and, later, consider server-side use of XSL

Browser-processed XSL Consider the XML specification below: Celia Larkin Bertie Ahern This refers to a XSL style-sheet, whose content we will examine later

Browser-processed XSL (contd.) When the XML document on the previous slide is loaded into an XSL-enabled browser it is rendered as shown below

Browser-processed XSL (contd.) The rendering on the previous slide is produced because the XML document is transformed, by the XSL style-sheet, into the following HTML document: Name Sex Celia Larkin female Bertie Ahern male

Browser-processed XSL (contd.) The XSL style-sheet which transformed the XML document into a HTML document is specified on the following slide We will then proceed to examine sufficient aspects of the XSL language to understand it

XSL style-sheet Name Sex male female

A short overview of the Extensible Stylesheet Language (XSL)

There are two main stages to rendering an XML document using XSL: –Tranforming the source document into a new notation which has a rendering semantics –Formatting the resultant document according to the semantics of the notation XSL provides two (sub-) languages for these two tasks

XSL provides a (sub-)language called XSL Transformations (XSLT) for tranforming a source XML document into a new notation which has a rendering semantics XSL provides a (sub-)language with rendering semantics called XSL Formatting Objects (XSL FO)

Re-using older notations We do not have to rely on XSL FO We can use XSL to transform XML into any other notation that has a rendering semantics For example, we can use XSLT to transform XML to HTML

Browser-side usage of XSL In browser-side usage of XSL, we simply use the XSLT part of XSL to transform XML into HTML This HTML is then rendered by the browser

Trees in XSLT In XSLT, the source and result document are viewed as trees –the types of nodes include element nodes, attribute nodes and text nodes. A stylesheet written in XSLT consists of a set of a set of template rules. A template rule has two parts: –a pattern which is matched against nodes in the source tree and –a template which can be instantiated to form part of the result tree.

XSLT Stylesheets An XSLT stylesheet is itself an XML document The root element is of type xsl:stylesheet but xsl:transform may be used as a synonym for xsl:stylesheet Thus, an XSLT stylesheet may look like this … Or like this: …

XSLT Stylesheets Two attributes are required for the root element: version – at present the correct value is “1.0” xmlns:xsl – at present, the correct values of this is " Thus, an XSLT stylesheet may look like this <xsl:transform version=“1.0” xmlns:xsl= " > …

Elements within the root element The root element ( xsl:stylesheet or xsl:transform ) may contain a great many different types of elements However, the most commonly-used element is the xsl:template element –Each xsl:template element is used to specify a template rule for transforming one kind of node in the tree for the source XML document

Fragment from an XSLT style-sheet The following shows the root node and first-level child nodes of an XSLT stylesheet <xsl:transform version=“1.0” xmlns:xsl=“ > …

xsl:template elements An xsl:template element is used to specify a template rule Each xsl:template element has a match attribute which is used to specify a type of node in the source tree The content of an xsl:template element specifies the corresponding structure in the result tree

The match attribute in xsl:template elements The match attribute in a template specifies the type of source node to which the template rule applies The value of a match attribute is an expression from a language called XPath We will consider XPath in more detail later For now, it is enough to know that an XPath expression simply specifies a certain class of node in an XML file An XPath expression may be as simple as a tag-name For example, the following template can be used to transform any person element … However, certain meta-characters may also be used in XPath expressions

Meta-characters in XPath patterns Meta-characters that may be used in match patterns include: / * | / // Here are some examples of patterns: –The pattern / matches the root node –The pattern * matches any element –The pattern male|female matches any male element and any female element –The pattern poem/verse matches any verse element with a poem parent –The pattern poem//line matches any line element with a poem element as an ancestor

The xsl:template element (contd.) Thus, here are some example xsl:template elements: …

Fragment from an XSLT style-sheet The following shows the top-most levels of the XSLT stylesheet for processing our XML document about Bertie and Celia <xsl:transform version=“1.0” xmlns:xsl=“ … The template matches the root element in the source document –The content of the template will specify how to generate the corresponding result document

Content of xsl:template elements The content of an xsl:template element specifies how to generate the result text that corresponds to the source node The content may –Simply specify some canned text –Contain XSLT instruction elements these specify certain kinds of processing that should be performed on the source node in order to compute the appropriate result text –Contain a mixture of canned text and XSLT instruction elements

Canned text in an XSLT stylesheet The stylesheet below transforms the entire source XML document (below-left) to some canned HTML text (below-right) People This document contains information about some people.

Canned HTML text must be well-formed XML The stylesheet below is not well-formed XML because there is no closing tag for the tag –An error message is produced by the MS XML parser People This document contains information about some people.