SDPL 2001Notes 6: XSL1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents:

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

1 XSL FO Extensible Stylesheet Language Formatting Objects An advanced style language for XML documents: An advanced style language for XML documents:
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
It’s All About Style The Basics of Style Sheets Presented by Barry Diehl.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XHTML & CSS 2 By Trevor Adams. Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
SDPL 2002Notes 6: XSL1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents:
1 XSL: Formatting Objects (FO) XSL-FO is about formatting XML data for output.
XSL Unit 6 November 2. XSL –eXtensible Stylesheet Language –Basically a stylesheet for XML documents XSL has three parts: –XSLT –XPath –XSL-FO.
Cascading Style Sheets Controlling the Display Of Web Content.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Cascading Style Sheets Controlling the Display Of Web Content.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Extensible Stylesheet Language (XSL) Brian Temple.
Introduction to XSL Hudson Ummem Veloso (huv) Luciano de Moura Silva (lms4)
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)
Week 0534Styling XML1 Topics CSS – styling XML for screen presentation –Associating CSS with XML –Selectors –Element positioning –Element appearance XSL.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
CIS 375—Web App Dev II XSLFO. 2 XSLFO IntroductionIntroduction XSLFO stands for Extensible Stylesheet Language ___________________. XSLFO is an _____-based.
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
Chapter 6 Web Typography. 2 Principles of Web Design Chapter 5 Objectives Understand principles for type design on a Web site Use the element Understand.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
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
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
XSL Formatting Objects „From XML to PDF“ Lecture on Walter Kriha.
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
XP Dreamweaver 8.0 Tutorial 3 1 Adding Text and Formatting Text with CSS Styles.
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,
Structured-Document Processing Languages Spring 2005 Course Review Repetitio mater studiorum est!
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
SDPL 2001Notes 4: Intro to Stylesheets1 4. Introduction to Stylesheets n Discussed recently: –Programmatic manipulation of (data-oriented) documents n.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
XML Steve Fisher/RAL. 20 October 2000XML - Steve Fisher/RAL2 Warning Information may not be all completely up to date.
Tutorial 3 Adding and Formatting Text with CSS Styles.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
Structured-Document Processing Languages Spring 2007 Course Review Repetitio mater studiorum est!
SDPL 2002Notes 4: Intro to Style Sheets1 4. Introduction to Style Sheets n Discussed recently: –Programmatic manipulation of documents n Now a more human-oriented.
SDPL 20076: XSL Formatting1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents:
SDPL 20064: Introduction to Style Sheets1 4. Introduction to Style Sheets n Discussed recently: –(APIs for) procedural manipulation of documents n Now.
SDPL 2004Notes 6: XSL Formatting1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
SDPL 2004Notes 4: Intro to Style Sheets1 4. Introduction to Style Sheets n Discussed recently: –Programmatic manipulation of documents n Now a more human.
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.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Working with Cascading Style Sheets
Unit 4 Representing Web Data: XML
CSS Layouts: Grouping Elements
Chapter 7 Representing Web Data: XML
XML Data Introduction, Well-formed XML.
How to Get Your Pages to Publish to PDF
Unit 6 - XML Transformations
Presentation transcript:

SDPL 2001Notes 6: XSL1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents: XSLT 2. XML vocabulary (of formatting objects) for specifying formatting semantics: XSL version 1.0, W3C Candidate Rec. (21-Nov-2001) n Introduction and Overview n Using XSL Formatting Objects

SDPL 2001Notes 6: XSL2 What is it? n An XSL style sheet specifies the presentation of a class of XML documents –by describing an XSLT transformation of the XML document into an XML document that uses the formatting vocabulary »XSL FO: a markup language to describe formatting n XSL builds on CSS2 and DSSSL –DSSSL a standardised but mainly unimplemented SGML style language

SDPL 2001Notes 6: XSL3 Example of XSL syntax Formatting paragraph elements ( p ): Formatting paragraph elements ( p ): –NB: An incomplete style sheet! <xsl:stylesheet version='1.0' xmlns:xsl=" xmlns:fo=" > xmlns:fo=" > <fo:initial-property-set <fo:initial-property-setfont-variant="small-caps"/> </xsl:template></xsl:stylesheet>

SDPL 2001Notes 6: XSL4 6.1 Overview of XSL Formatting n A style sheet processor accepts an XML document and an XSL style sheet, and produces a formatted presentation n Two steps: –tree transformation: XML source tree  result tree (using XSLT) –formatting »by interpreting the result tree to produce formatted presentation

SDPL 2001Notes 6: XSL5 Transformation & Formatting

SDPL 2001Notes 6: XSL6 Basis of formatting n Tree transformation adds information needed to format the result tree n Formatting semantics expressed using a formatting vocabulary, of –formatting objects (FOs), nodes of the result tree »for typographic abstractions like page, block, line, page reference, … »XSL 1.0 defines 56 formatting object classes –formatting properties control the presentation of formatting objects »indents, spacing, fonts, … »XSL 1.0 defines 246 formatting properties

SDPL 2001Notes 6: XSL7 Formatting n Formatting-object tree interpreted to produce the representation n Each FO specifies a part of pagination, layout and styling applied to its content n Properties control the formatting of a FO –some directly, e.g., color –some through constraints, e.g., space- before.minimum  rendered form not uniquely defined by XSL

SDPL 2001Notes 6: XSL8 Area tree n Formatting generates an area tree consisting of geometric areas –areas may nest: glyphs within lines, lines within blocks, blocks within a page n Rendering causes the area tree to appear on a medium –areas printed on a sequence of sheets (or displayed on a single scroll in a browser)

SDPL 2001Notes 6: XSL9 Generating the Area Tree n Formatting a gradual and complex process n Element and attribute tree –target of transformation, source of formatting –consists of element, attribute, and text nodes –transformed into a … n Formatting object tree –consists of formatting objects with properties –more detailed: each character its own object

SDPL 2001Notes 6: XSL10 Generating the Area Tree (2) n Properties of the formatting object tree refined into traits –e.g., by propagating inherited properties, and computing absolute values for relative properties »e.g., properties font-size="12pt", start-indent="2em" become traits font-size="12pt", start-indent="24pt" –traits control generation of areas out of formatting objects –some traits only available as a result of formatting, e.g., page numbers

SDPL 2001Notes 6: XSL11 Generating the Area Tree (3)

SDPL 2001Notes 6: XSL12 Benefits of XSL n a comprehensive model and vocabulary for expressing XML stylesheets n pagination and layout model extend existing ones –area model a superset of the CSS2 box model n support of non-western-language directions –distances may be specified in terms of before, after, start and end, relative to “ writing-mode ” n source selection and manipulation (XPath/XSLT) powerful

SDPL 2001Notes 6: XSL13 XSL Area Model n Each area tree node (except root) is an area, and is associated to a rectangular portion of the output medium n Areas are generated by formatting objects n An area has a content-rectangle –portion for child areas –optionally surrounded by a border and padding

SDPL 2001Notes 6: XSL14 Content, Padding and Border XSL contains (for compatibility) also CSS-like margins; normally margins of blocks controlled through space- before, space- after, start- indent and end- indent

SDPL 2001Notes 6: XSL15 Two area types n block-areas –generated in block-progression-direction (normally top-to-bottom) –paragraphs normally rendered using fo:block, which creates block areas –line-area a special case: no borders or padding n inline-areas –generated in inline-progression-direction (normally left-to-right) –characters rendered using fo:character, which generates glyph-area inline-areas »no child areas, a single glyph image as content

SDPL 2001Notes 6: XSL16 Formatting objects and properties XSL 1.0 defines 56 formatting objects … XSL 1.0 defines 56 formatting objects … page-sequence, simple-page-master, block, inline, list-block, list-item, list-item-label, list- item-body, external-graphic, basic-link, float, footnote,... page-sequence, simple-page-master, block, inline, list-block, list-item, list-item-label, list- item-body, external-graphic, basic-link, float, footnote,... n and 246 properties background-color, font-family, font-size, space- before, end-indent, text-align, text-indent, … background-color, font-family, font-size, space- before, end-indent, text-align, text-indent, …

SDPL 2001Notes 6: XSL17 Some central formatting objects fo:root fo:root –top node of the formatting object tree fo:simple-page-master fo:simple-page-master –guides the creation of pages –specifies the geometry of pages »region-body (for page content) »region-before, region-after, region-start and region-end (for header, footer, and left and right sidebar) fo:page-sequence fo:page-sequence –specifies the creation of page sequences –possibly different page-sequence (and page-master) for, say, each chapter

SDPL 2001Notes 6: XSL18 More formatting objects fo:flow fo:flow –child objects of page-sequence s –flows attached to regions of a page-master –content of flows distributes to regions of pages n NB: No ‘page’-formatting objects –pages created by the formatter fo:block fo:block –commonly used for paragraphs, titles, … fo:inline fo:inline –to change properties (e.g., font-style ) of inline text

SDPL 2001Notes 6: XSL19 “Hello world” result tree as XSL document <fo:page-sequence <fo:page-sequence master-name="page"> master-name="page"> Hello World Hello World </fo:root>

SDPL 2001Notes 6: XSL20 Implementations? W3C XSL WG considers Candidate Recommendation stable, and encourages implementation W3C XSL WG considers Candidate Recommendation stable, and encourages implementation mentions 9 products/prototypes, e.g., mentions 9 products/prototypes, e.g., –XEP by RenderX »commercial (  $5000, April 2001) »Java-based XSL-FO to PS/PDF processor –Apache FOP

SDPL 2001Notes 6: XSL21 Apache FOP n FOP (Formatting object to PDF) by J. Tauber »“fop: a man who pays too much attention to his appearance” –donated to XML Apache project ( ) –open-source freeware –Java-based XML/XSL-FO to PDF (or MIF/PCL/TXT) processor n Implements a subset of XSL 1.0 Candidate Rec; Version : –39 formatting objects (out of 56) –110 formatting properties (out of 246)

SDPL 2001Notes 6: XSL22 An XSL-FO Example n From J. David Eisenberg: Using XSL Formatting Objects. XML.com, January 17, 2001 n XSL FOs for a CD-ROM version of a handbook of Spanish –No one would mark-up document instances using XSL formatting objects by hand –Instead, think of this as the result of an XSLT transformation Overall structure of fo:root : specification of Overall structure of fo:root : specification of –page masters, followed by –the content of the pages

SDPL 2001Notes 6: XSL23 Example: Page dimensions and margins <fo:layout-master-set> <fo:simple-page-master master-name="cover" <fo:simple-page-master master-name="cover" page-height="12cm" page-height="12cm" page-width="12cm" page-width="12cm" margin-top="0.5cm" margin-top="0.5cm" margin-bottom="0.5cm" margin-bottom="0.5cm" margin-left="1cm" margin-left="1cm" margin-right="0.5cm"> margin-right="0.5cm"> …</fo:layout-master-set> with similar simple-page-master s with with similar simple-page-master s with –master-name="rightPage" (identical) –master-name="leftPage" (left and right margins switched)

SDPL 2001Notes 6: XSL24 Example: Page regions A simple page can contain 1-5 regions, specified by child elements of the simple-page-master A simple page can contain 1-5 regions, specified by child elements of the simple-page-master n Let us refine the page masters by specifying regions

SDPL 2001Notes 6: XSL25 Example: Region dimensions <fo:simple-page-master master-name="cover" <fo:simple-page-master master-name="cover" … dimensions and margins as above … > … dimensions and margins as above … > … Regions of rightPage identical to leftPage Regions of rightPage identical to leftPage Note: body has no extent; it gets the remaining area Note: body has no extent; it gets the remaining area –margins of body have to accommodate other regions

SDPL 2001Notes 6: XSL26 Example: Page Sequences Next: masters for sequences of content pages, using the defined simple-page-master s Next: masters for sequences of content pages, using the defined simple-page-master s –repeatedly alternate masters for left and right pages:

SDPL 2001Notes 6: XSL27 Page Sequences Other attributes of conditional-page-master- reference to select the page master to be used : Other attributes of conditional-page-master- reference to select the page master to be used : –page-position="first" »or "last", or "rest" (neither first or last), or "any" –blank-or-not-blank="true" (or "false" ) »for example, to generate a blank page to force chapters to end at odd-numbered pages n Next: Specifying the sequences of content pages –by naming masters to be used, and attaching flow s to regions

SDPL 2001Notes 6: XSL28 Example: Contents of the Cover Page Spanish Review Handbook Copyright © 2001 J. David Eisenberg A Catcode Production Spanish Review Handbook Copyright © 2001 J. David Eisenberg A Catcode Production

SDPL 2001Notes 6: XSL29 Example: Cover Page Formatted Formatting the first page- sequence produces page: Formatting the first page- sequence produces page:

SDPL 2001Notes 6: XSL30 Example: Content Pages Finally, we specify a page-sequence for the content pages Finally, we specify a page-sequence for the content pages –with static-content for the header and footer, and a flow for page bodies Spanish Review Handbook Spanish Review Handbook

SDPL 2001Notes 6: XSL31 Example: Content Pages Continue n Specify content for the footer: Página Página n Finally, specify the content of page body:

SDPL 2001Notes 6: XSL32 Example: Content Pages Continue Assign a flow of blocks to region-body : Assign a flow of blocks to region-body : Watch this space! Watch this space! n Formatting and rendering this gives …

SDPL 2001Notes 6: XSL33 Example: Content Pages Formatted

SDPL 2001Notes 6: XSL34 How About Practise? n As said, no one would write XSL FO document instances by hand n Instead, XSLT style rules are used to create appropriate XSL formatting objects –page masters for match="/" –page-sequences with flows for major structural elements (like chapters, or the entire document) –content elements would be mapped to blocks, inlines, list-blocks, tables, … as appropriate

SDPL 2001Notes 6: XSL35 Examples of mapping content elements n For example, headers:

SDPL 2001Notes 6: XSL36 Examples of mapping content elements Formatting in-line emphasis: Formatting in-line emphasis: </xsl:template> n More examples in the exercises

SDPL 2001Notes 6: XSL37 Summary n It is a standard! –well, almost: a W3C Candidate Recommendation –emerging implementations seem promising n XSL is a powerful (and complex) style language for XML documents –allows arbitrary transformations of input documents –allows fine-tuned specification of formatted representation