Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.

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.
Introduction to HTML & CSS
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
XML: Extensible Markup Language
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
 2001 Prentice Hall, Inc. All rights reserved. 1.
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.
XSL XSLT and XPath 11-Apr-17.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XML Unit 6 October 31. XML, review XML is used to markup data Used to describe information Uses tags like HTML –But all tags are user-defined –Must be.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
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.
LBSC 690: Session 6 CSS, XML/XSLT Jimmy Lin College of Information Studies University of Maryland Monday, October 15, 2007.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
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.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
Basics of HTML.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
Julien Thibault  HTML is the basic building-blocks of webpages  It is not a language!! (despite its name)  Structure text/media.
Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate.
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.
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 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding.
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.
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
HTML Concepts and Techniques Fourth Edition Project 12 Creating and Using XML Documents.
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 "
Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
IST 221 Internet Concepts and Applications Introduction to XML II CSS and XSLT Style Sheets.
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.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
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.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Accessing XML Documents Using DOM ©NIITeXtensible Markup Language/Lesson 8/Slide 1 of 23 Objectives In this lesson, you will learn to: * Use XML DOM objects.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
XML Extensible Markup Language
Displaying Data with XSLT ©NIITeXtensible Markup Language/Lesson 6/Slide 1 of 45 Objectives In this lesson, you will learn to: * Perform conditional formatting.
XML Schema – XSLT Week 8 Web site:
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 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 1 of 28 Objectives In this lesson, you will.
In this session, you will learn to:
XML: Extensible Markup Language
Creating an XSLT Style Sheet for Formatting Data
Unit 6 - XML Transformations
Presentation transcript:

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify the need for style sheets * Create a cascading style sheet * Create an XSLT for formatting data

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 2 of 46 Rendering XML documents * Rendering refers to the act of processing an XML document so that it can be displayed on a variety of targets, such as Web browsers, , pagers, and cellular phones. Style Sheets * A style sheet is a document that contains formatting rules for one or more XML documents. * It contains the code to instruct the Web browser on how to translate the structure of the source document into a structure that can be displayed.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 3 of 46 What does a Style Sheet Allow you to do? * A style sheet allows you to perform the following tasks: 3 Transform an XML document into another structure for the purpose of rendering it to a specific target. This may include: ä Generating constant text, such as labels and headings ä Specifying filters for extracting the required data ä Changing the sequence of elements and attributes ä Sorting the content ä Performing complex transformations that compute values based on the existing content

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 4 of 46 What does a Style Sheet Allow you to do? (Contd.) 3 Describe how to present the transformed information. Description of presentation includes: ä Screen or page layout ä Assignment of transformed content into lists and paragraphs ä Specification of properties such as spacing, margins, alignment, and fonts

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 5 of 46 Problem Statement 5.D.1 * CyberShoppe wants to display the details of all the products that it sells. The product details need to be displayed in a browser in the format specified below: 3 The price per unit, description, and quantity on hand for each product should be displayed in teal color with a font size of 10 pts. 3 The name of the product must be displayed in red with a font size of 20 pts. It should be displayed in bold. 3 All details must be displayed in the Arial font.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 6 of 46 Task List * Identify the elements to be displayed. * Identify a mechanism to display formatted data. * Create a style sheet to format data. * Apply the style sheet to the XML document. * View the document in a browser.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 7 of 46 Task 1:Identify the elements to be displayed. Result * As per the given scenario, the elements that have to be displayed are: 3 PRODUCTNAME 3 PRICE 3 DESCRIPTION 3 QUANTITY

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 8 of 46 Task 2:Identify a mechanism to display formatted data. * Cascading Style Sheets (CSS) 3 A Cascading Style Sheet (CSS) is a type of style sheet that provides a simple mechanism for adding styles to an XML or HTML document. 3 A CSS is a text file containing one or more rules or definitions for the style characteristics of a particular element. 3 The CSS file can be included in a number of XML documents that have the same data structure.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 9 of 46 Task 2:Identify a mechanism to display formatted data. (Contd.) * Result 3 As CSS allows you to format data in an XML document, CSS can be used to display the products data stored in the XML document in the specified format.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 10 of 46 Task 3:Create a style sheet to format data. * CSS allows you to format the contents of a document by specifying the element name followed by the formatting instructions for that element. The syntax for coding a CSS is as follows: elementname { property1: value; property2: value; property3: value; }

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 11 of 46 Task 3:Create a style sheet to format data. (Contd.) Action * Type the code for creating the style sheet and save the file as product.css.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 12 of 46 Task 4:Apply the style sheet to the XML document. * In order to apply the formatting specifications given in the CSS file to the data in an XML document, you need to associate the CSS with the XML document. * This can be done using the following syntax:

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 13 of 46 Task 5:View the document in a browser.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 14 of 46 Just a Minute… *The details about all the books sold at CyberShoppe are to be displayed in the following format: 3 The book name is to be displayed in blue, Times New Roman, size 20pts, and bold. 3 The first name and last name of the author are to be displayed in green, Arial, and size 10pts. 3 Price of the book is to be displayed in red, Times New Roman, and size 20pts. *Create a CSS for displaying the book details in the above format.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 15 of 46 Problem Statement 5.D.2 * CyberShoppe needs to display product details, such as product ID, name of the product, and price per unit. In the output, all details about products should be displayed in red.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 16 of 46 Task List * Identify the data to be displayed. * Identify a mechanism for displaying selective data in a sorted order. * Identify the elements required to display selective data in a sorted order. * Create a style sheet. * Apply the style sheet to the XML document. * View the XML document.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 17 of 46 Task 1:Identify the data to be displayed. Result * As per the given scenario, the data that is to be displayed is as follows: 3 PRODID 3 PRODUCTNAME 3 PRICE

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 18 of 46 Task 2:Identify a mechanism for displaying selective data in a sorted order. * CSS does not support operations, such as reordering and sorting elements based on a condition, and displaying only selective elements. * To help you perform such operations, XML supports another style sheet language called eXtensible Style Sheet Language (XSL). * XSL is made up of the following parts: 3 XSL Transformations (XSLT): It is an XML-based language that allows you to transform an XML document into another XML document.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 19 of 46 Task 2:Identify a mechanism for…(Contd.) 3 XML Path (XPath): It is a language that is used to access different parts of an XML document, such as elements and attributes. * XSL uses XSLT to transform an XML document that contains data. * XSLT contains instructions for specifying how an XML document is to be transformed. * XSLT uses XPath expressions to extract specific data from an XML document.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 20 of 46 Task 2:Identify a mechanism for…(Contd.) * A software called XSLT processor reads the instructions given in XSLT and transforms the XML document into another XML document, which uses formatting objects of XSL to display the XML document in the desired format.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 21 of 46 Task 2:Identify a mechanism for…(Contd.) Comparison between XSLT and CSS * XSLT is a superset of the CSS functionality. * XSLT is an application of XML. Therefore, it follows the XML syntax, whereas CSS has its own syntax. XML and CSS can co-exist since they meet different needs. * XSLT is intended for complex formatting.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 22 of 46 Task 2:Identify a mechanism for…(Contd.) * Working of the XSLT Processor XSLT style sheet XML document Result tree MSXML Parser XSLT tree Source tree XSLT processo r

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 23 of 46 Task 2:Identify a mechanism for…(Contd.) Result * Since XSL gives you added functionality of extracting specific data from an XML document, XSL can be used to select data as per the scenario. * You need to use XSLT, which is a part of XSL, to create a style sheet. This style sheet should contain the instructions for transformation of an XML document into the result tree.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 24 of 46 Task 3:Identify the elements required to display selective data in a sorted order. * XSLT provides a number of elements for selecting and formatting data. * Some of the XSLT elements are: 3 stylesheet 3 value-of 3 for-each 3 sort 3 text

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 25 of 46 Task 3:Identify the…sorted order. (Contd.) * The stylesheet element 3 Since an XSLT style sheet contains instructions for transforming XML documents, a declaration is added in the XSLT file to instruct the browser that it is a style sheet file. This declaration is known as style sheet declaration. 3 The syntax for style sheet declaration is as follows:

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 26 of 46 Task 3:Identify the…sorted order. (Contd.) * The value-of element 3 This element displays the value of the element or attribute specified. The syntax for using this element is as follows: 3 If you want to display the value of an attribute, you must use the symbol as a prefix with the attribute name.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 27 of 46 Task 3:Identify the…sorted order. (Contd.) * The for-each element 3 This element is used to instruct the XSLT processor to process the information for each instance of the specified pattern. 3 The syntax for using the for-each element is as follows: [action to be performed]

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 28 of 46 Task 3:Identify the…sorted order. (Contd.) * The for-each element (Contd.) 3 The select attribute of the for-each element allows you to specify the elements or attributes on which the action needs to be performed. 3 The XSLT transformation instructions within the for-each element are applied to each of the nodes selected by the select attribute of the for- each element.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 29 of 46 Task 3:Identify the…sorted order. (Contd.) * The sort element 3 XSLT provides the sort element for sorting data based on values assigned to elements and attributes. 3 The sort element does not contain any child elements. 3 This element is always used as a child of the for- each element or the apply-templates element.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 30 of 46 Task 3:Identify the…sorted order. (Contd.) * The sort element (Contd.) 3 The syntax for using the sort element is as follows: <xsl:sort select="expression" order="ascending|descending" case-order="upper-first|lower-first“ data-type="text|number|qname"/>

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 31 of 46 Task 3:Identify the…sorted order. (Contd.) * The text element 3 The text element allows you to generate constant text in the output. 3 This element can be used to display labels.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 32 of 46 XSLT Template Rules * XSLT allows you to define template rules for the output. * A template rule describes how an XML element and its contents are converted into a format that can be displayed in the browser. * A template rule consists of two parts: ä A pattern that identifies an XML element in an XML document. ä An action or processing code that details the transformation and rendering of the resulting element.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 33 of 46 XSLT Template Rules (Contd.) * XSLT uses two main elements for creating template rules, template and apply-templates. * The template Element 3 The template element is used to define a template for the desired output. The syntax for using this element is as follows: [action to be taken]

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 34 of 46 XSLT Template Rules (Contd.) * The apply-templates Element 3 This element is used to instruct the XSLT processor to find an appropriate template and perform the specified tasks on each selected element. 3 The syntax for using this element is as follows: 3 The select attribute is optional and is used to specify the context in which the template should be executed.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 35 of 46 XSLT Template Rules (Contd.) * The apply-templates Element (Contd.) 3 You can effectively use templates in order to display data. 3 The XSLT processor always starts processing from the root node. Therefore, it starts processing from the template rule. 3 If you have more than one template rule created for the same element, the previous template rule will be overridden by the other template.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 36 of 46 XSLT Template Rules (Contd.)

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 37 of 46 XSLT Template Rules (Contd.) Default Template * To prevent the processing of templates from stalling when there is no suitable selection rule, the XSLT processor assumes a default template rule.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 38 of 46 XSLT Template Rules (Contd.) Default Template (Contd.) * The default template rule consists of the following statements:

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 39 of 46 Task 3:Identify the…sorted order. (Contd.) Result *The following XSLT elements are used to extract and format the required data: 3stylesheet: To specify the style sheet declaration. 3for-each: To display the product ID, product name, and price for each instance of the product element. 3value-of: To display the values of PRODID, PRODUCTNAME, and PRICE. 3sort: To sort the elements and attributes containing product details based on the product ID. 3text: To display the labels for various elements and attributes. 3 template: To be used as the parent element of the for- each element.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 40 of 46 Task 4:Create a style sheet.Action * As per the scenario, the product details, such as PRODUCTID, PRODUCTNAME, and PRICE have to be sorted in the ascending order of the PRODID attribute. * To do this, type the necessary code as save the file as product1.xsl.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 41 of 46 Task 5:Apply the style sheet to the XML document. * To view selective details of a product, such as product ID, name, and rate from an XML document, you need to associate the XML document with the XSL file that renders the required data. * This can be done using the following syntax: Action * Type the code for creating the XML document as save the file as product.xml.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 42 of 46 Task 6:View the XML document.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 43 of 46 Problem Statement 5.P.1 * CyberShoppe wants to display the details of all books to its customers. The book details that have to be displayed are book ID, title, and rate of books. The book details must be displayed in the ascending order of rate and book ID.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 44 of 46 Summary In this lesson you learned that: * Rendering is the process of presenting the data in an XML document in different formats. * A style sheet is a separate document that contains the formatting rules for one or several XML documents. * There are two types of style sheets used with XML documents. They are: 3 Cascading Style Sheets (CSS) 3 eXtensible Stylesheet Language (XSL)

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 45 of 46 Summary (Contd.) * CSS is used to define the style or appearance of an XML document. * XSL is made up of XSL Transformations (XSLT) and XML Path (XPath). * XSLT is a superset of the CSS functionality. * XSLT is used to display selective elements or attributes, sort data on one or more elements, and process the data on the basis of a condition. * XSLT elements, such as template, apply- templates, sort, for-each, and value-of are used to extract and format data.

Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 46 of 46 Summary (Contd.) * An XSLT style sheet contains a set of templates rules. A template rule describes how an XML element and its contents are converted into a format that can be displayed in the browser. * Each template rule has two parts: a pattern and an action. * The reference to a style sheet file is included in an XML document by using the syntax