XSL eXtensible Stylesheet Language. What is XSL? XSL is a language that allows one to describe a browser how to process an XML file. XSL can convert an.

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.
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.
XSL XSLT and XPath 11-Apr-17.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
XML XML What XML is and what it means to me as a Computer Scientist By: Derek Edwards CS 376 March 10, 2003.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
INF201 Fall2010 Intro. to Info. Technologies Department of Informatics University at Albany – SUNY Original Source: w3schools.com Prepared by Xiao Liang,
13 February Building a Web Page. HTML Files Two types of information Text Instructions on how to display Instructions are in the form of tags Tags are.
CSE 190: Internet E-Commerce Lecture 17: XML, XSL.
XML CS 105. What is XML? XML stands for Extensible Markup Language. XML is a markup language like HTML. XML was designed to describe data. You must define.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley A Case Study in Database Organization The iDiary Database lawrence snyder.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Understanding HTML Style Sheets. What is a style?  A style is a rule that defines the appearance and position of text and graphics. It may define the.
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.
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
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.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
HTML. We’ll learn … What HTML is What tags are What a basic web page looks like What 3 HTML tags are required What HTML comments look like How to title.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
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.
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
Basic HTML Hyper text markup Language. Re-cap  … - The tag tells the browser that this is an HTML document The html element is the outermost element.
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
XML A Single Entity. xml a single entity Objectives Objectives :  understand the data model  describe the XML Document  describe the XML Schema  describe.
HTML. WHAT IS HTML HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup language A markup language is a set of.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
XML About XML Things to be known Related Technologies XML DOC Structure Exploring XML.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Unit 2, cont. September 12 More HTML. Attributes Some tags are modifiable with attributes This changes the way a tag behaves Modifying a tag requires.
How do I use HTML and XML to present information?.
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.
IST 221 Internet Concepts and Applications Introduction to XML II CSS and XSLT Style Sheets.
Presentation Topic: XML and ASP Presented by Yanzhi Zhang.
Lecture 11 XSL Transformations (part 1: Introduction)
CIS 275—Web App Dev I XML. 2 Introduction to XMLXML XML stands for ________________________. HTML was designed to display data. XML was designed to _________.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
HTML: Hyptertext Markup Language Doman’s Sections.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
HTML ( HYPER TEXT MARK UP LANGUAGE ). What is HTML HTML describes the content and format of web pages using tags. Ex. Title Tag: A title It’s the job.
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.
Dr. Chunbo Chu Week 3. XML Not a replacement for HTML. XML and HTML were designed with different goals: XML was designed to transport and store data,
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.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Chapter 29. Copyright 2003, Paradigm Publishing Inc. CHAPTER 29 BACKNEXTEND 29-2 LINKS TO OBJECTIVES Attach an XML Schema Attach an XML Schema Load XML.
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.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
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
Creating an XSLT Style Sheet for Formatting Data
Tutorial 04 (cont’) Using XPath Patterns in an XSLT Style Sheet.
Presentation transcript:

XSL eXtensible Stylesheet Language

What is XSL? XSL is a language that allows one to describe a browser how to process an XML file. XSL can convert an XML file into another XML with different format. XSL can convert an XML file into a non-XML file.

XSL The most common type of XSL processing is to convert XML file into HTML file which can be displayed by browsers. We will focus on this use of XSL. XSL is the bridge between XML and HTML. We can use XSL to have different HTML formats for the same data represented in XML. Separating data (contents) from style tags (display commands). XML example, class.xml

XML Tree (Logical Structure)

XSL Example for class.xml (XML  HTML) Class.xml Stylesheet The homepage of

Try it yourself Down load class.xml and class.xsl from homepage of the course. Save it on your machine. View the XML file with web browser. Add the line that instructs the browser which stylesheet to use to format the XML (add it to second line). View the XML file again.

XSL The first line of the XSL file shows that XSL itself is written in XML. ( ). Line: tells the browser that this is a XSL stylesheet. The XSL tags specify the rules to be applied to elements or attributes of the XML. Any other tag, including HTML tags, or piece of text will be kept as it is.

XSL paths Using XSL paths we can display the content of the elements or values of the attributes. “/” by itself represents the root element. When “/” is used as separator between two elements it indicates a move one level down the hierarchy. Example: /, class, class/title or class/students/student/name/first

XSL Paths The browser can also pick out and use attribute values. The syntax Example:

XSL template Each template contains rules to apply when an element is matched with the path specified as value of the match attribute. Thus, …. means apply the rules within the start and end tags to the root element.

XSL value-of The element is used to extract the value of the element or attribute specified in select attribute. Examples:

Do it yourself 1-Copy this piece of XML and save it as note.xml: John Merry Don’t forget mer 2- View it using an web browser.

Do it yourself 3- Write an XSL stylesheet for note which displays note as: There was a message from John to Merry with title Reminder. 4- Note John is written in bold and Merry italic. 5- Name the stylesheet as note.xsl 5- Add the line which instructs the browser to style note.xml with note.xsl. 6- View note.xml with a web browser.

Do it yourself 3- Write an XSL stylesheet for note which displays note as: There was a message from John to Merry with title Reminder. 4- Note John is written in bold and Merry italic. 5- Name the stylesheet as note.xsl 5- Add the line which instructs the browser to style note.xml with note.xsl. 6- View note.xml with a web browser.

Note Stylesheet There was a message from (Sample Solution) to with title.

Redo it. Write an XSL stylesheet which displays the note.xml in the following form (HTML table):

Note Stylesheet From To Message Title (Sample Solution)

HW2 I posted assignment #2. Let’s review it together.

More XML Create your own XML file for a Lunch Menu. The root element should be. The sub elements of are corresponding to each food in the menu. Then each element has a number of attributes or child elements (your choice) such as name, price, calories,…. Add at least two entries to your XML tree. View the result using a web browser. (Make sure it is well-formed).

Cheese Burger $ Macaroni and Cheese $ (Sample Solution) Hot Dog $

Repetition Using we can retrieve the value of element or attribute which matches the XSL path specified by the select attribute. But what if there are more than one element or attribute which matches with the specified path and we want to apply some formatting rules on all these matched entities?

Example In class.xml we have couple of student elements which match with the XSL path: class/students/student Assume we want to create an style-sheet which lists the name of all students in class. We need an XSL instruction to apply a set of rules on each student element.

… allows us to specify a set of styling rules within the start and end tags to be applied to all elements or attributes which match the specific path in select attribute. Example: Write an XSL stylesheet for class.xml where each student name is in a separate line and with bold face.

Example of Student Names

Exercise 1.Download and save class-names.xml into your machines. 2.Download and save XSL-EX-1.xsl into your machines in the same folder. 3.Modify the style-sheet, so instead of name of students you have an unordered list of majors of students of the class. (Remember, the HTML syntax for unordered list: … ) 4.View the classView.xml with a web browser.

Sample Solution Student Majors

Problem Some students have not yet decided their majors. For these students the value of decided attribute is “n”. But the formatting rules inside the will be applied to all students regardless of having a major or not. We want a way to instruct the XSL to apply the rules when the value of decided attribute is “y” (decided = “y”).

Selection: Filtering Data is yet another xsl tag which instructs the XSL to apply the rules within start tag and end tag if the value of the specified element or attribute matches with the value specified at the right hand side of “=”. Put it another way, conditionally retrieves the value of the specified element or attribute. This condition is specified as value of match attribute.

Specifying the Condition inside match attribute Test path : XSL path which specifies the element or attribute we want to perform the test on its value. Value : The conditional value. That is if the value of the specified element or attribute matches this value the rules or instructions within start and end tags will be executed.

Examples o “.” in XSL is shorthand for “the current node”. o Select the current element IF its sub-element, majorName has value MGT. <xsl:if = ‘y’] o Select the current element if the value of “decided” attribute of its sub-element, major is ‘y’.] o Select the current element IF the value of the child, submajor of its child, major is ‘Finance’.

Different Web Browsers Note that the standard syntax for suggested by W3C is:

With the standard syntax for, the tag should be: <xsl:stylesheet version="1.0“ xmlns:xsl=" Instead of: <xsl:stylesheet xmlns:xsl=" You can use any of them, but the second case works only with Internet Explorer.

Example List the name of the majors of all students in the class. Use to avoid empty items.

Major Names (Sample Solution 1)

Do it yourself I.Download and save the file XSL-EX-3.xsl. II.Change the appropriate line in class- names.xml to be styled with XSL-EX-3.xsl. III.View class.xml with a browser. IV.Change the XSL-EX-3.xsl to present the class.xml as a table with a column for student names and another column for their major. If the student has no major, the phrase N/A should appear in major column.

Things to remember HTML table tags : header … data …. You need to use and two within it.