1 XSL: Formatting Objects (FO) XSL-FO is about formatting XML data for output.

Slides:



Advertisements
Similar presentations
CREATED BY : VIRAL M.KORADIYA. Anchor elements are defined by the element. The element accepts several attributes, but either the Name or HREF attribute.
Advertisements

1 XSL FO Extensible Stylesheet Language Formatting Objects An advanced style language for XML documents: An advanced style language for XML documents:
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
A really fairly simple guide to: mobile browser-based application development (part 1) Chris Greenhalgh G54UBI / Chris Greenhalgh
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)
XHTML and CSS Overview. Hypertext Markup Language A set of markup tags and associated syntax rules Unlike a programming language, you cannot describe.
XHTML1 Tables and Lists. XHTML2 Objectives In this chapter, you will: Create basic tables Structure tables Format tables Create lists.
1 XSL: Formatting Objects (FO) XSL-FO is about formatting XML data for output.
Creating a Web Page with Tables. Objectives Create a text table with preformatted text Create the basic structure of a graphical table Organize table.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Developing a Basic Web Page with HTML
Tags through Forms. This element is required for all HTML pages It must be at the top of every page of every website We’ll see later on why it is important.
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.
1 The Structure of a Web Table beginning of the table structure first row of three in the table end of the table structure table cells You do not need.
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.
ITP 104.  While you can do things like this:  Better to use styles instead:
_ HTML, XHTML & CSS Sami Niemelä | Module 1: Introduction to digital media: Day 02.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
CS 299 – Web Programming and Design Introduction to HTML.
HTML (HyperText Markup Language)
Amber Annett David Bell October 13 th, What will happen What is this business about personal web pages? Designated location of your own web page.
XSL Formatting Objects „From XML to PDF“ Lecture on Walter Kriha.
Chapter 4: Hypertext Markup Language Primer TECH Prof. Jeff Cheng.
Learning Web Design: Chapter 4. HTML  Hypertext Markup Language (HTML)  Uses tags to tell the browser the start and end of a certain kind of formatting.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
XP Mohammad Moizuddin Creating Web Pages with HTML Tutorial 1 1 New Perspectives on Creating Web Pages With HTML Tutorial 1: Developing a Basic Web Page.
CHAPTER 10 Formatting Tables and Forms. Using Tables the Right Way  HTML and XHTML have a LOT of tags dedicated to building a table  If you have only.
Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding.
10/4/2015Tables1 Spring, 2008 Modified by Linda Kenney 4/2/08.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
Essentials of HTML Class 4 Instructor: Jeanne Hart
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
IS1824: Introduction to Internet Multimedia Lecture 5: Layout in HTML Rob Gleasure
4 Chapter Four Introduction to HTML. 4 Chapter Objectives Learn basic HTML commands Discover how to display graphic image objects in Web pages Create.
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. Office Word 2007 Lab 3 Creating Reports and Tables.
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.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
CSS Fun damentals The Document Hierarchy Element Relationships The Box Model.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
WEEK -1 ACM 262 ACM 262 Course Notes. HTML What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML.
Positioning Objects with CSS and Tables
Web Page Tables GMU-Teaching with Technology. Table Characteristics: Looks like a news page Contains columns and rows.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CS134 Web Design & Development Attributes, Lists, Tables, Links, and Images Mehmud Abliz.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
HTML. HTML: What is it? – HTML stands for Hyper Text Markup Language – An HTML file is a text file containing small markup tags – The markup tags tell.
INT222 – Internet Fundamentals
Chapter 5 pp HTML Elements & Attributes Format Content Or Examples This Text Is A Hyperlink.
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.
Glencoe Introduction to Web Design Chapter 4 XHTML Basics 1 Review Do you remember the vocabulary terms from this chapter? Use the following slides to.
CSS.
Working with Cascading Style Sheets
CSS Applications to XML 19-Sep-18.
Styles and the Box Model
Second CSS Lecture Applications to XML
Cascading Style Sheets™ (CSS)
CSS Applications to XML 20-May-19.
Session IV Chapter 15 - How Work with Fonts and Printing
CSS Applications to XML 3-Jul-19.
Presentation transcript:

1 XSL: Formatting Objects (FO) XSL-FO is about formatting XML data for output

2 Introduction Apache-FOP Document Structure Output –Page –Flow –Block –Inline List Table Links and Cross-Reference Graphics

3 Introduction What is XSL-FO (formatting objects)? –XSL-FO stands for Extensible Stylesheet Language Formatting Objects  Styling is both about transforming and formatting information –XSL-FO is about formatting  XSL-FO is an XML based markup language describing the formatting of XML data for output to screen, paper or other media –XSL-FO is a W3C Recommendation  XSL-FO became a W3C Recommendation 15. October Formally named XSL –XSLFO is an XML vocabulary that is used to specify a pagination and other styling for page layout output

4 Introduction (cont.) XSLFO can be used in conjunction with XSLT to convert from any XML format into a paginated layout ready for printing or displaying XSLFO defines a set of elements in XML that describes the way pages are set up. The contents of the pages are filled from flows. There can be static flows that appear on every page (for headers and footers) and the main flow which fills the body of the page

5 Introduction (cont.) The Object Formatting Process –Use an XSLT stylesheet to transform the XML document into a file of XSL-FO elements –To perform the transformation, you simply invoke the XSLT processor with the XML document and the stylesheet  An XSLT stylesheet that converts XHTML elements into formatting objects –Use a rendering engine (for example, FOP) to convert the XSL-FO elements into a PDF file

6 Software Tool Set Up XSL-FO Processors FOP (Formatting Objects Processor) from apache – –Version: the version of FOP Requirement –XML parser –XSLT Processor –Apache Batik: an SVG library

7 Apache FOP Introduction –FOP (Formatting Objects Processor) is the world's first print formatter driven by XSL formatting objects (XSL-FO) –The world's first output independent formatter –A Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output –Output formats currently supported include PDF, PCL, PS, SVG, XML (area tree representation), Print, AWT, MIF and TXT –The primary output target is PDF –The latest version of FOP (0.20.5) is a partial implementation of the XSL-FO Version 1.0 W3C RecommendationXSL-FO Version 1.0 W3C Recommendation

8 Apache FOP (cont.)

9 FOP process –Uses the standard XSL-FO file format as input –Lays the content out into pages –Renders it to the requested output –One great advantage to using XSL-FO as input is that XSL-FO is itself an XML file, which means that it can be conveniently created from a variety of sources –The most common method is to convert semantic XML to XSL- FO, using an XSLT transformation

10 Apache FOP (cont.) FOP Objectives –The goals of the Apache XML FOP Project are to deliver an XSL-FO file to a PDF formatter –Conformance to the XML 1.0 Recommendation, XSLT 1.0 Recommendation and the XML Namespaces Recommendation –The FOP layout system is currently being rewritten to better support the XSL-FO standard For detail information regarding the spec. of FOP, visit:

11 XSL-FO Document XSL-FO documents are XML files with output information –They contain information about the output layout and output contents –XSL-FO documents are stored in files with a *.fo or a *.fob extension XSL-FO document structure at a glance Most of the things in the figure never change Output slide

12 XSL-FO Document (cont.) XSL-FO Document Structure XSL-FO documents have a structure like this: The contains a and a. The contains page layouts information, The contains actual content

13 XSL-FO Document (cont.) The element contains the XSL-FO document. It also declares the namespace for XSL-FO: ……………. ……………. Typically, the root element contains A Followed by one or more s

14 XSL-FO Document (cont.) The element contains one or more page templates: The element specifies page definitions. In a simple document, one layout might be enough, Complex documents typically have several page definitions. Use a element to define each of the page layouts you need; Then you store them in the element

15 XSL-FO Document (cont.) Each element contains a single page template The element defines the layout for a particular page Each template must have a unique name (master-name):

16 XSL-FO Document (cont.) Here's an example, master-name Defines a name for this page master. You can create several different elements Then refer to each of them as you need to use different page layouts throughout your document. margin-top and margin-bottom Define the margins at the top and bottom of the page. Acceptable units are points, picas, inches, and centimeters <fo:simple-page-master master-name="main" margin-top="36pt" margin-bottom="36pt" page-width="8.5in" page-height="11in" margin-left="72pt" margin-right="72pt"> <fo:region-body margin="50pt" />

17 XSL-FO Document (cont.) page-width and page-height Define the size of the physical page. This example defines a letter-sized page; To use A4-sized paper, the attributes page- width="21cm" and page-height="29.7cm" would do the trick. margin-left and margin-right Define the margins at the left and right side of the page. <fo:simple-page-master master-name="main" margin-top="36pt" margin-bottom="36pt" page-width="8.5in" page-height="11in" margin-left="72pt" margin-right="72pt"> <fo:region-body margin="50pt" />

18 Units in XSL-FO documents XSL-FO supports these actual units for length properties, for measuring items such as margin-left, page-width, and page-height: UnitMeaning cmcentimeters mmmillimeters ininches ptpoints (72 points = 1 inch) pcpicas (12 points = 1 pica, 6 picas = 1 inch) px pixels (sometimes different from one formatter or device to the next, so be careful) emthe width of a capital M

19 The element The XSL-FO spec defines five regions on a page –region-body defines the dimensions of the main area in the center of the page. Here's a sample: –margins for the region-body area. –region-before, the area at the top of the page (normally used for running heads) –region-after, the area at the bottom of the page (normally used for running feet) –region-start, the area to the left of the page –region-end, the area to the right of the page

20 Margin Top MarginLeft MarginLeft MarginRightMarginRight Margin Bottom REGION BEFORE REGIONSTARTREGIONSTART REGION BODY REGIONENDREGIONEND REGION AFTER Note: These definitions assume that the text in your document goes from left to right and top to bottom

21 XSL-FO Document (cont.) -- Page One or more elements describe page contents (i.e., output pages) It defines the sequence of page layouts to be used within the document The master-reference attribute refers to the “master-name” of the with the same name Each output page refers to a page master which defines the layout Each output page has a element defining the output Each output page is printed (or displayed) in sequence Note: The master-reference "A4" does not actually describe a predefined page format. It is just a name. You can use any name like "MyPage", "MyTemplate", etc.

22 XSL-FO Output Output? How to insert some content to be rendered XSL-FO defines output inside elements XSL-FO Page, Flow, and Block –"Blocks" of content "Flows" into "Pages" and then to the output media –XSL-FO output is normally nested inside elements, nested inside elements, nested inside elements Structure What’s this?

23 An Output Example Hello W3Schools Hello Class of Web ProgrammingII Simple1 Error in the text book

24 XSL-FO Output -- : refers to slides #20 XSL-FO pages are filled with data starts from elements defines some content that will be flowed within the current layout When the page is full, the same page master will be used over (and over) again until all the text is printed. The legal values are: xsl-region-body (into the region-body) xsl-region-before (into the region-before) xsl-region-after (into the region-after) xsl-region-start (into the region-start) xsl-region-end (into the region-end) format

25 XSL-FO Output -- Two main XSL-FO elements for formatting content are and Blocks are sequences of output in rectangular boxes Think of it as similar to the HTML element. A element always causes a line break This block of output will have a one millimeter border around it.

26 XSL-FO Output -- (cont.) Since block areas are rectangular boxes, they share many common area properties:  space before and space after  margin  border  padding Note: for the attributes of each, refers to W3c spec. The content area contains the actual content like text, pictures, graphics, or whatever. space before margin border padding content space after

27 An XSL-FO Blocks Example <fo:block font-size="14pt" font-family="verdana" font-color="red“ space-before="5mm" space-after="5mm"> W3Schools <fo:block text-indent="5mm" font-family="verdana" font-size="12pt“ space-before="5mm" space-after="5mm"> At W3Schools you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP. Simple2 Normally XSL-FO document do not combine formatting information and content like we have done here

28 XSL-FO Output -- The formatting object is commonly used for formatting a portion of text It defines some text properties within an existing –If you want to italicize several words within a paragraph, as in the example, you use to do the job. This is a paragraph of text. font size = 20 pt, line height = 30pt, Notice that we applied fo:inline here: this meaningless prose, the inline stops here. drones on and on, the FOP software automatically calculates line breaks for us. Isn't that fascinating? Simple3

29 XSL-FO Output -- Here's how you can use the attributes of XSL-FO element to format text: –Bold text: Use the element with an attribute of font- weight="bold". –Italicized text: Use the element with an attribute of font- style="italic". –Monospaced text: Use the element with an attribute of font- family="monospace". –Changing fonts: Use the element with an attribute of font- family="serif" for a serif font (usually similar to Times-Roman). –Use the attribute font-family="sans-serif" for a sans serif font (usually similar to Arial). – See the FOP documentation for information on how to convert the fonts installed on your machine into fonts FOP can use Others:

30 XSL-FO Properties Many XSL-FO properties are identical to the CSS properties you might recognize. XSL-FO and CSS also share the same way that elements usually inherit properties from their ancestors An XSL-FO property is just an XML attribute

31 XSL-FO -- list The three most common types of lists in HTML : –unordered lists –ordered lists –definition lists When building these lists with XSL-FO, you must handle a number of things yourself: –How much horizontal space separates the label of a list item (the bullet or number) and the item itself –How much the list items are indented from the normal margins

32 XSL-FO – list (cont.) When building these lists with XSL-FO, you must handle a number of things yourself (cont.): –What the bullet character is –How much vertical spacing falls between list items Other properties Almost all of these properties are handled automatically in an HTML browser, but when you use formatting objects, it's up to you to define them.

33 XSL-FO – list (cont.) XSL-FO uses list-blocks to define lists There are four XSL-FO objects used to create lists: –fo:list-block (contains the whole list) –fo:list-item (contains each item in the list) –fo:list-item-label (contains the label for the list-item - typically an containing a number, character, etc.) –fo:list-item-body (contains the content/body of the list-item - typically one or more objects)

34 XSL-FO – list (cont.) XSL-FO uses list-blocks to define lists There are four XSL-FO objects used to create lists: –fo:list-block (contains the whole list) –fo:list-item (contains each item in the list) –fo:list-item-label (contains the label for the list-item - typically an containing a number, character, etc.) –fo:list-item-body (contains the content/body of the list-item - typically one or more objects)... More s

35 XSL-FO – list (cont.) The main structure is the It contains some number of s, each of which contains A ………… ………….. …………. ………….

36 XSL-FO – list (cont.) An Example * Volvo * Saab list1

37 XSL-FO – list (cont.) Trouble to separate the label and content? Time to look at some properties that can make a change Taking a look at this drawing that outlines a list and its properties – : defines the distance from the normal ending margin and the end of the elements – : defines the distance from the normal starting margin to the start of either the or. The body-start() function returns the value of the start-indent property of plus the provisional-distance- between-starts property of. label-end() function returns the value of the start-indent property of the element minus the value of the provisional-label- separation property of the element

38 XSL-FO – list (cont.) In the picture, two properties of the element, –provisional-distance-between-starts : defines the distance between the start of the and the –provisional-label-separation: defines the distance between the end of the and the start of the Here's a typical with these properties specified: <fo:list-block provisional-distance-between-starts="0.75cm" provisional-label-separation="0.5cm"> Let’s applied these properties to the previous example list2

39 XSL-FO – list (cont.) How to convert HTML tags to FO? for example: List item 1. List item 2. List item 3. Refers to “formatting objects for lists” Objects-for-Lists lists

40 XSL-FO – table The is used to format the tabular material of a table. The contains – Each of these elements has one or more objects, with one or more objects: XSL-FO elementDescription Formats the tabular material of a table Formats the columns of a table Defines a table header Container for table rows and table cells Defines a table footer Defines a table row Defines a table cell Formats a table and its caption

41 XSL-FO – table The basic table structure –Information of the table: caption, header, and footer –The main complication in formatting XSL-FO tables with FOP is that you must specify the widths of all columns in the table A typical example: table1

42 XSL-FO – table : An Example Three different styles of tables are presented in this example We can only demo here, refers the example code after class tables

43 XSL-FO : links and Cross-Reference Related topics –Creating anchor points –Creating cross-references –Creating Web links Anchor points –Creating an anchor point is pretty simple; all you have to do is add an id attribute to an XSL-FO element –You can add this attribute to just about any formatting object. –Here's an example document heading with an id of “BID” –This ID creates an anchor point in the XSL-FO file with the name “BID”. –If the XSL-FO file contains another element with an id of “BID”, you'll get an error. <fo:block id=“BID" font-size="18pt" line-height="21pt" font-weight="bold"> cross-references

44 XSL-FO : links and Cross-Reference Cross-Reference Once you've created an anchor point, you can create a reference to it. Here's what a reference might look like: For more information, see Links and cross-references. interlink

45 XSL-FO : links and Cross-Reference Web-Reference The main difference here is that the thing you're linking to isn't part of the PDF file. XSL-FO defines the external-destination property of the element for this. Here's what an XSL-FO reference to a html file in local drive would look like For all the technical information you'd ever want, visit <fo:basic-link color="blue" external-destination="file://CompSci196.htm"> KIMO and prepare to be amazed! Externlink

46 XSL-FO : links and Cross-Reference Example demo –Cross reference:Internal link –Web reference:External link links

47 XSL-FO Graphics To add graphics to a PDF file throughout the FO file, use the element. –Here's an example: You can use this element to embed GIF and JPEG images in PDF files. The XSL-FO spec also defines the height and width attributes; Those element and attributes help the FOP engine figure out how much room the graphic requires. exmGraph

48 That’s it for today! Next week We’ll have –XSL-FO vs. XSLT! –XSL-FO Graphics – SVG –Content pages –Some advanced XSL-FO technologies