©CSW Group Ltd 2005 Intermediate XSLT Bob DuCharme these slides: 1.0.

Slides:



Advertisements
Similar presentations
Chungnam National University DataBase System Lab
Advertisements

Introduction to XSL XSL-BASIC ELEMENTS. Transforming XML XSL file 1 XSLT Processor WML fileXSL file 2HTML fileXML file Contenuto Forma Documento.
Copyright © 1999, Architag International Corporation. All rights reserved. Use without express written permission from Architag International Corporation.
Copyright © 2003 Pearson Education, Inc. Slide 4-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Transforming XML XMLNamespaces, XSLT. XML Namespaces Sometimes it is necessary to mix XML elements –Different types of content –Use of markup to convey.
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.
Learn about Cascading Style Sheets LACUNY Web Management Roundtable October 21, 2005
Advanced XSL Learn how to use advanced XSLT techniques, EXSLT, and Xalan extensions to solve complicated problems Cascade Server User’s ConferenceAmy.
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
Presenter: James Huang Date: Sept. 26,  Introduction  Basics  Lists  Links  Forms  CSS 2.
Part 2 Introduction to CSS. CSS Syntax – class selector 1 With the class selector you can define different styles for the same type of HTML element. You.
It’s All About Style The Basics of Style Sheets Presented by Barry Diehl.
Technology Reviews :XSL Park, Ho-gun. What is XSL Extensible Style sheet LanguageExtensible Style sheet Language An XML-based language used to.
 2001 Prentice Hall, Inc. All rights reserved. 1.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XML: Styling and Transformation Dr Andy Evans. Multiple views Nice thing is that this data can be styled in lots of different ways using stylesheets.
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.
An Introduction to XML Based on the W3C XML Recommendations.
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.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
XSLT Stylesheets Some more advanced examples (adapted from the Edinburgh LT site)
XSLT eXtensible Stylesheet Language Transformations Naveed Arshad.
XML Workshop XSLT. XML Tagged data Hello A really interesting course, well taught Interchange of data RSS, BPEL4WS, RossettaNet … Structure document representation.
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.
XSLT XSLT: eXtensible Stylesheet Language for Transformations - a language for transforming XML documents into any text- based format (e.g. HTML, plain.
CSS Cascading Style Sheets By Garrett Garman. CSS Why use Style Sheets? Separates Appearance and Structure Modularity Quick and Easy changes Flexibility.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
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 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.
IST 221 Internet Concepts and Applications Introduction to XML II CSS and XSLT Style Sheets.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
CIS 375—Web App Dev II XSL. 2 XSL Introduction XSL stands for _____________________________. XSL is the language used for manipulating and displaying.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
ITB Web programming for E- Commerce 1 ITB6227 Programming for E-COMMERCE Lecture Presentation of XML Documents.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
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.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates.
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.
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:
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:
CSS Cascading Style Sheets
Unit 4 Representing Web Data: XML
Creating an XSLT Style Sheet for Formatting Data
Chapter 7 Representing Web Data: XML
What Color is it?.
Querying XML XSLT.
More XML XML schema, XPATH, XSLT
Presentation transcript:

©CSW Group Ltd 2005 Intermediate XSLT Bob DuCharme these slides: 1.0

Outline Variables and parameters Named templates and parameters xsl:for-each and “looping” XSLT extensions and EXSLT Using keys for faster lookups XSLT and browsers

Variables <xsl:stylesheet version="1.0" xmlns:xsl=" John Congratulations,, you are a winner! Input document: Output: Congratulations, John, you are a winner!

Passing Parameters to Stylesheets <xsl:stylesheet version="1.0" xmlns:xsl=" John Congratulations,, you are a winner! Same input document, same result, but when we override the default parameter value: C:\>saxon temp.xml test.xsl winnerName=Jane Congratulations, Jane, you are a winner!

Named Templates

Passing Parameters to Named Templates h4 <xsl:with-param name="headerElement">h1 <xsl:with-param name="headerElement" select="'h2'"/>

Iterating across a set of nodes <xsl:stylesheet version="1.0" xmlns:xsl=" output:

Repetition 1 -

Testing the recursive template rule Print 1 hyphen: Print 20 hyphens: Print 0 hyphens:

Recursive template rule: result Print 1 hyphen: - Print 20 hyphens: Print 0 hyphens:

XSLT Extension functions <xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:saxon="

Testing the extension function Source document: test Result: /a /a/b[1] /a/b[2] /a/b[2]/c[1] test /a/b[3]

Extension elements (and attributes) <xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:saxon=" extension-element-prefixes="saxon"> <xsl:variable name="i" select="0" saxon:assignable="yes"/> The value of i is

Extension element test output The value of i is 0 The value of i is 1 The value of i is 2 The value of i is 3 The value of i is 4 The value of i is 5 The value of i is 6 The value of i is 7 The value of i is 8 The value of i is 9

Checking for extension support (option 1) The value of i is Your XSLT processor doesn't support saxon:while.

Checking for extension support (option 2) The value of i is Your XSLT processor doesn't support saxon:while. checking for extension function support: function-available()

EXSLT Saxon documentation on its extensions: “ Before using a Saxon extension, check whether there is an equivalent EXSLT extension available. EXSLT extensions are more likely to be portable across XSLT processors.”

Some EXSLT extensions (pt 1) <xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:exsl=" xmlns:math=" xmlns:date=" exsl:object-type(3): exsl:object-type('potrzebie'): exsl:object-type(2 > 1):

Some EXSLT extensions (pt 2) math:constant('PI',4): math:constant('PI',12): math:sqrt(256): date:date-time: date:day-name:

EXSLT demo result exsl:object-type(3): number exsl:object-type('potrzebie'): string exsl:object-type(2 > 1): boolean math:constant('PI',4): math:constant('PI',12): math:sqrt(256): 16 date:date-time: T11:24:12-04:00 date:day-name: Saturday same result with Saxon and Xalan Java!

Declaring and using lookup keys we have: yellow blue orange green oxford button-down poly blend, straight collar monogrammed, tab collar we want: blue oxford button-down yellow poly blend, straight collar white monogrammed, tab collar

Without keys <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:variable name="shirtColorCode" <xsl:value-of = $shirtColorCode]"/>

With keys <xsl:stylesheet version="1.0" xmlns:xsl="

How key lookup works

More lookups (part 1) <xsl:stylesheet version="1.0" xmlns:xsl=" c4 colorKey Looking up the color name with the color ID: c3's color: c4's color: c8's color: c7's colors:

More lookups (part 2) Looking up the color ID with the color name: blue's cid: black's cid: gray's cid:

More lookups: result Looking up the color name with the color ID: c3's color: red c4's color: blue c8's color: c7's colors: orange green Looking up the color ID with the color name: blue's cid: c4 black's cid: c2 gray's cid:

Muenchian Grouping <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:for-each select= "file[count(. | = 1]">, bytes

Muenchian Grouping: result jupiter gadabout.pas,685 bytes kwatz.xom,43 bytes potrzebie.dbf,1102 bytes mars schtroumpf.txt,389 bytes swablr.eps,4313 bytes ummagumma.zip,2441 bytes neptune batboy.wks,424 bytes mondegreen.doc,1993 bytes paisley.doc,988 bytes

Web Browsers and XSLT W3C Recommendation "Associating Style Sheets with XML documents" ( shows how:

Web Browsers and XSLT (part 1) <xsl:stylesheet version="1.0" xmlns:xsl=" <!-- squareAsHTML.xsl: create an HTML document with a statement about the square of each "number" element read from the source tree. --> Squares body { font-family: arial,helvetica; } h1 { font-size: 14pt } p { font-size: 10pt} Squares

Web Browsers and XSLT (part 2) The square of is. You could create your HTML like this: saxon -o numbers.html numbers.xml squareAsHTML.xsl

XSLT 2.0 Lots more built-in functions Writing your own functions Regular expressions Grouping output by values Tokenizing strings Typing awareness