SDPL 20076: XSL Formatting1 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 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
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:
Chapter 6 Web Typography
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
CSS, cont. October 12, Unit 4. Creating a Sidebar We know how to create a sidebar –Use the float property div#sidebar{ float: left; } Item1 Item2 Item3.
HTML and XHTML Controlling the Display Of Web Content.
1 XSL: Formatting Objects (FO) XSL-FO is about formatting XML data for output.
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)
XSL Formating Object Pagination of Documents. Generating PDF XML document XSLT Engine XSLT Style sheet XSL-FO Document XSL-FO Formatter Printable document.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
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.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
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.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
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.
CO1552 – Web Application Development Cascading Style Sheets.
SDPL 2001Notes 4: Intro to Stylesheets1 4. Introduction to Stylesheets n Discussed recently: –Programmatic manipulation of (data-oriented) documents n.
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)
XML Steve Fisher/RAL. 20 October 2000XML - Steve Fisher/RAL2 Warning Information may not be all completely up to date.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Tutorial 3 Adding and Formatting Text with CSS Styles.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
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 20064: Introduction to Style Sheets1 4. Introduction to Style Sheets n Discussed recently: –(APIs for) procedural manipulation of documents n Now.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Structured-Document Processing Languages Spring 2004 Course Review Repetitio mater studiorum est!
SDPL 2004Notes 6: XSL Formatting1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML.
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.
SDPL 2001Notes 6: XSL1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents:
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
Web Design Principles 5 th Edition Chapter 3 Writing HTML for the Modern Web.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
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.
Unit 4 Representing Web Data: XML
Chapter 7 Representing Web Data: XML
How to Get Your Pages to Publish to PDF
Presentation transcript:

SDPL 20076: XSL Formatting1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents: XSLT 2. XML vocabulary for specifying formatting: XSL 1.0, W3C Rec. 10/01; XSL 1.1 Rec. 12/06 »written for implementers of XSL processors n 6.1 Introduction and Overview n 6.2 XSL Formatting by Example

SDPL 20076: XSL Formatting2 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 an ISO-standardised, but mainly unimplemented SGML style language

SDPL 20076: XSL Formatting3 Example of XSL Syntax n Formatting paragraphs (as part of a complete style sheet) <xsl:stylesheet version='1.0' xmlns:xsl=" xmlns:fo=" > xmlns:fo=" > 1]"> 1]"> </xsl:stylesheet>

SDPL 20076: XSL Formatting4 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: 1. (XSLT) transformation: XML source tree  result tree 2. (XSL FO) formatting »interprets the result tree to produce formatted presentation

SDPL 20076: XSL Formatting5 Transformation & Formatting XSLT script

SDPL 20076: XSL Formatting6 Basis of formatting n Transformation adds info 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-sequence, block, in-line text, page reference, … »XSL 1.0 defines 56 FO classes (XSL 1.1 adds 25) –formatting properties control the presentation of formatting objects (indents, spacing, fonts, …) »248 formatting properties; many common with CSS2

SDPL 20076: XSL Formatting7 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 and space-before.optimum  final rendering is not unique

SDPL 20076: XSL Formatting8 Areas and Area Tree n Formatting generates an area tree consisting of nested rectangular areas –inline areas (e.g. glyph areas) within line areas –lines within block areas –blocks within regions of a page n Rendering causes the area tree to appear on a medium –areas printed on a sequence of sheets (or displayed as a single scroll in a browser)

SDPL 20076: XSL Formatting9 Generating the Area Tree (1/3) n Formatting a gradual and complex process n Conceptual process of XSL formatting: n (XSL FO) Element and attribute tree –target of transformation, source of formatting –consists of element, attribute, and text nodes –transformed into a … n Formatting object tree (  XSL FO Elem&attr tree) –consists of formatting objects with properties –more detailed: each character its own object

SDPL 20076: XSL Formatting10 Generating the Area Tree (2/3)

SDPL 20076: XSL Formatting11 Generating the Area Tree (3/3) n Properties of the formatting object tree refined into traits (muotoilupiirre, piirre) –e.g., by propagating inherited properties, and computing absolute values for relative properties »e.g., properties font-size="12pt", text-indent="2em" become traits font-size="12pt", text-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 20076: XSL Formatting12 Benefits and Usage of XSL n Powerful selection and manipulation (← XSLT) n Extended pagination and layout capabilities –area model a superset of the CSS2 box model »e.g., different writing directions; footnotes, page number refs. n Support of non-western writing directions –> distances in terms of before/after (for block-progression- direction), and start/end (for inline-progression-direction) n "XSL most useful to produce tailored, paginated documents on a server, in response to individual customer requests” (S. Deach, XSL 1.0 co-author, Adobe)

SDPL 20076: XSL Formatting13 XSL Area Model n Formatting objects generate areas –each 0 or more »page breaks  additional block areas »line breaks  additional line areas n Each area tree node (except root) associated to a rectangular portion of the output medium n An area has a content-rectangle –portion for child areas –optionally surrounded by a border and padding

SDPL 20076: XSL Formatting14 Content, Padding and Border For CSS- compatibility also margin-top, -right, -bottom and -left space-before space-after start- indent end-indent space-startspace-end space-start/end not supported by FOP

SDPL 20076: XSL Formatting15 Two area types n block-areas –generated in block-progression-direction ( before -> after ; normally top-to-bottom) –paragraphs and titles 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 ( start -> end ; 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 20076: XSL Formatting16 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, table, table-row, table-column,... page-sequence, simple-page-master, block, inline, list-block, list-item, list-item-label, list- item-body, external-graphic, basic-link, float, footnote, table, table-row, table-column,... n and 248 properties master-reference, background-color, font-family, font-size, space-before, start-indent, end- indent, text-align, text-indent, … master-reference, background-color, font-family, font-size, space-before, start-indent, end- indent, text-align, text-indent, … –many common with CSS2

SDPL 20076: XSL Formatting17 Some central formatting objects 1/3 fo:root fo:root –top node of the formatting object tree –a wrapper for all the rest fo:simple-page-master fo:simple-page-master –model of the geometry of pages »region-body (for page content) »region-before (for header), region-after (for footer), region-start and region-end (for left and right sidebar)

SDPL 20076: XSL Formatting18 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

SDPL 20076: XSL Formatting19 Top-level formatting objects n Slightly simplified: fo:root fo:layout-master-set (fo:simple-page-master | fo:page-sequence-master)+ fo:page-sequence + fo:region- body fo:region- before? fo:region-end? fo:region-start? fo:region- after? specify masters for page sequences by referring to simple-page-masters contents of pages fo:flow

SDPL 20076: XSL Formatting20 Some central formatting objects 2/3 fo:page-sequence fo:page-sequence –specifies the creation of page sequences –possibly different page-sequence (and page- sequence-master) for, say, each chapter fo:flow fo:flow –child of a page-sequence –Attribute flow-name connects to a region with a matching region-name –> the contents is distributed to that region of pages n NB: There are no ‘page’-formatting objects –pages created by the formatter

SDPL 20076: XSL Formatting21 Content objects for pages n Slightly simplified: fo:static-content* Block-level object+ fo:page-sequence + fo:flow Block-level object+ (repeated on every page) every page) (distributed to pages) to pages)

SDPL 20076: XSL Formatting22 Some block-level objects fo:block fo:block –commonly used for paragraphs, titles, … –may contain text, other block s, or »fo:inline (to change properties, e.g., font-style of inline text) fo:table for formatting tabular material fo:table for formatting tabular material fo:list-block to format lists of fo:list-block to format lists of –fo:list-item s of » fo:list-item-label and »fo:list-item-body

SDPL 20076: XSL Formatting23 “Hello world” result tree as an XSL document <fo:page-sequence <fo:page-sequence master-reference="page"> master-reference="page"> Hello World Hello World </fo:root>

SDPL 20076: XSL Formatting24 Implementations? W3C XSL Rec rather recent (10/01, 12/07) W3C XSL Rec rather recent (10/01, 12/07) n What is the state of implementations? n Some promising/interesting ones (2004): –XEP by RenderX (XSL-FO to PS/PDF formatter), XSL Formatter by Antenna House »$0 … $5,000 (evaluation … server versions; April 2004) –Adobe Document Server –Passive TeX »set of TeX macros to process XSL-FO by Sebastian Rahtz –Apache FOP

SDPL 20076: XSL Formatting25 Apache FOP n FOP (Formatting Objects Processor) 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 PS/SVG/TXT/...) processor –Not complete, but implements a useful subset of XSL 1.0

SDPL 20076: XSL Formatting26 FOP 0.93 XSL-FO Compliance Implementedfullypartiallynototal formattingobjects 39 39(66%) 6 (10%) (10%) (24%) (24%) (incl. 3 XSL 1.1 bookmark FOs) formattingproperties (64%) (8%) (8%) (28%) (28%) (non-aural) –16 of 18 core functions implemented

SDPL 20076: XSL Formatting XSL-FO by Example n From J. David Eisenberg: Using XSL Formatting Objects. XML.com, January 17, 2001, (acknowledging the loan of some graphics) n XSL FO instance for a handbook of Spanish –NB: XSL FO is not designed to be hand-authored –Consider this as a machine-generated 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 20076: XSL Formatting28 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> plus similar simple-page-master s with plus similar simple-page-master s with –master-name="rightPage" (identical) –master-name="leftPage" (left and right margins switched)

SDPL 20076: XSL Formatting29 Intended layout of pages

SDPL 20076: XSL Formatting30 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´s refine the page masters with regions

SDPL 20076: XSL Formatting31 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 … > NB: body uses all space inside page margins  margins of region-body have to accommodate other regions! NB: body uses all space inside page margins  margins of region-body have to accommodate other regions!

SDPL 20076: XSL Formatting32 Layout of Page Regions 3 cm

SDPL 20076: XSL Formatting33 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: –repeatedly alternate masters for left and right pages:

SDPL 20076: XSL Formatting34 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="blank"/"not-blank" n Next: Specifying the sequences of content pages –by naming masters to be used, and connecting content flow s to regions

SDPL 20076: XSL Formatting35 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 20076: XSL Formatting36 Example: Cover Page Formatted Formatting the first page-sequence gives... Formatting the first page-sequence gives...

SDPL 20076: XSL Formatting37 Example: Content Pages Finally, a page-sequence for content pages Finally, a page-sequence for content pages –with static-content for the header and footer, and a flow for contents of pages: Spanish Review Handbook Spanish Review Handbook

SDPL 20076: XSL Formatting38 Example: Content Pages Continue n Content for page footers: Página Página n Finally, specify the content of the page body:

SDPL 20076: XSL Formatting39 Example: Content Pages Continue Assign a flow of block s to region-body : Assign a flow of block s to region-body : Watch this space! Watch this space! n Formatting and rendering this gives …

SDPL 20076: XSL Formatting40 Example: Content Pages Formatted

SDPL 20076: XSL Formatting41 Using FOs in Practise n XSL FO instances should not be created manually n Instead, use XSLT rules to create formatting objects –fo:root with layout masters for match="/" –page-sequence s with a flow for major parts (like chapters, or the entire document): … –page-sequence s with a flow for major parts (like chapters, or the entire document): …

SDPL 20076: XSL Formatting42 Mapping content elements –content elements would be mapped to blocks, inlines, list-blocks, tables, … as appropriate n For example, headers:

SDPL 20076: XSL Formatting43 Examples of mapping content elements Formatting in-line emphasis: Formatting in-line emphasis: n More in the exercises

SDPL 20076: XSL Formatting44 Summary n It is a standard! –well, almost: a W3C Recommendation –emerging implementations seem promising –currently used mainly for producing PDF »browser support being expected … 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