XSL-FO TUTORIAL-FROM W3SCHOOLS.com

xiaoxiao2021-03-06  42

Introduction to XSL-FO

XSL-FO IS ABOUT FORMATTING XML DATA for Output.

What you shop already know Know

Before You Study XSL-FO You Should Have A Basic Undering of XML and XML Namespaces.

If You Want To Study Thase Subjects First, please read out our xml tutorial.

What is xsl-fo?

XSL-FO IS A LANGUAGE FORMATTING XML DATA XSL-FO Stands for Extensible Stylesheet Language Formatting Objects XSL-FO IS A W3C Recommendation XSL-FO Is Now Formally Named XSL

XSL-fo is about formatting

.

XSL-fo is formally named XSL

Why this confusion? Is xsl-fo and xsl the Same Thing?

YES IT IS, But We Will Give You An Explanation:

Styling is both about transforming and formatting information. When the World Wide Web Consortium (W3C) made their first XSL Working Draft, it contained the language syntax for both transforming and formatting XML documents.

Later the xsl working group at w3c split the Original Draft INTO SEPARATE Recommendations:

XSLT, A Language for Transforming Information XSL or XSL-FO, A LANGUAGE FORMATTINGTION INFORMATION XPATH, A LANGUAGE for DEFINING Parts of An XML Document

The Rest of this Tutorial Is About Formatting Information: XSL-FO Also Called XSL.

You can read more about xslt in our xlt tutorial.

You can read more about xpath in yur xpath tutorial.

XSL-FO IS A Web STANDARD

XSL-FO BECAME A W3C Recommendation 15. October 2001. Formally Named XSL.

To read more about the xsl Activities At W3c Please Read Our W3C Tutorial.

XSL-FO Documents

XSL-FO Documents Are XML Files with Output Information.

XSL-FO Documents

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. It is also quite normal to see XSL -Fo Documents Stored with The * .xml Extension, Because this makes themed.

XSL-FO Document Structure

XSL-FO Documents Have A Structure Like this:

Structure Explained

XSL-FO Documents Are XML Documents, And Must Always Start with an XML Declaration:

The Element Contains the xsl-fo document. It also declares the namespace for xsl-fo:

The Element contains one or more page templates:

Each ELEMENT CONTAINS A SINGLE PAGE TEMPLATE. Each Template Must Have a Unique Name (Master-name):

One or more Elements Describe page contents. The master-reference attribute refers to the simple-page-master template with the Same Name:

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.

XSL-FO AREAS

XSL-FO Uses Rectangular Boxes (Areas) To Display Output.

XSL-FO AREAS

The xsl formatting model defines a Number of Rectangular Areas (Boxes) To Display Output.

All Output (Text, Pictures, or wherever) Will Be Formatted Into these Boxes and the displayed or printed to a target media.

We Well Take a Closer Look at The Following Areas:

Pages Regions Block Areas Line Areas Inline Areas

XSL-FO PAGES

XSL-FO OUTPUT IS FORMATTED INTO PAGES. Printed Output Will Normally Go Into Many Separate Pages. Browser Output Will OFTEN Go INTO One Long Page.

XSL-FO PAGES Contain Regions.

XSL-FO Regions

Each XSL-FO Page Contains a Number of Regions:

Region-body (The Body of the Page) Region-at (The Footer of the Page) Region-start (The Left Sidebar) Region-End (The Right Sidebar)

XSL-FO Regions Contain Block is.

XSL-FO Block Areas

XSL-FO BLOCK AREAS Define Small Block Elements (The ons That Normal Starts with a new line) Like Paragraphs, Tables and Lists.

XSL-FO BLOCK AREAS CAN Contain Other Block Areas, But Most Offen The Contain Line Areas.

XSL-FO LINE AREAS

XSL-FO LINE AREAS Define Text Lines Inside block.

XSL-FO LINE AREAS Contain Inline.

XSL-FO INLINE AREASXSL-FO INLINE AREAS Define Text Inside Lines (Bullets, Single Character, Graphics, And More).

XSL-FO OUTPUT

XSL-FO Defines Output Inside Elements.

XSL-FO PAGE, FLOW, AND BLOCK

"Blocks" of content "flows" INTO "Pages" and the to the output media.

XSL-FO OUTPUT IS NORMALLY NESTED INSISIDE Elements, Nested Inside Elements, Nested Inside Elements:

XSL-FO EXAMPLE

IT IS TIME to Look At A Real XSL-FO EXAMPLE:

Hello W3Schools

The Output from this Code Would Be Something Like this:

Hello W3Schools

XSL-FO FLOW

XSL-FO PAGES ARE FILLED with DATA from Elements.

XSL-FO Page SEQUENCES

XSL-FO Uses Elements to define output pages.

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.

XSL-FO FLOW

XSL-FO PAGES ARE FILLED WITH Content from the Element.The element contains all the elements to be printed to the page.

WHEN The page is full, The Same Page Master Will Be Used over (AND over) Again Until All The text isprinted.

WHERE TO FLOW?

The Element Has A "flow-name" attribute.

The value of the flow-name attribute defines where the content of the element will go.

The Legal Values ​​Are:

XSL-Region-Body (INTO THE REGON-BODY) XSL-Region-Afore (INTO THE REGON AFTER) XSL-Region-Start (INTO THE RION-START) XSL- Region-End (INTO THE REGON-END)

XSL-FO PAGES

XSL-FO Uses Page Templates Called "Page Masters" to Define The Layout of Pages.

XSL-FO Page Templates

XSL-FO Uses Page Templates Called "Page Masters" To Define The Layout of Pages. Each Template Must Have a Unique Name:

In The Example Above, Three Elements, Define Three Different Templates. Each Template (Page-Master) HAS A DIFFERENT NAME.

The First Template is Called "Intro". It could be used as a template for Introduction Pages.

The Second and Third Templates Are Called "Left" and "right". They could be used as templates for even and odd points

XSL-FO Uses The Following Attributes To Define The Size of A Page:

Page-width defines the width of a page Page-height defines the height of a page

XSL-FO Page Margins

XSL-FO Uses The Following Attributes To Define The Margins of A Page:

Margin-top defines the top margin-bottom defines the Bottom Margin Margin-Right Defines The Right Margin Margin Defines All Four Margins

XSL-FO Page Regions

XSL-FO Uses The Following Elements to Define The Regions of A Page:

region-body defines the body region region-before defines the top region (header) region-after defines the bottom region (footer) region-start defines the left region (left sidebar) region-end defines the right region (right sidebar)

Note that the region-before, region-after, region-start, and region-end is a part of the body region. To avoid text in the body region to overwrite text in these regions, the body region must have margins at least the SIZE OF SESE.

Margin Top Margin LEFT

Region BEFOREGIONSTART Region Body Region endRegionAfuterMarginright Margin Bottom

XSL-FO EXAMPLE

This is an extract from an xsl-fo document:

Page-width = "297mm" Page-height = "210mm"

Margin-top = "1cm" margin-bottom = "1cm"

Margin-left = "1cm" margin-right = "1cm">

The Code Above Defines A "Simple Page Master Template" with the name "a4".

The Width of the page is 297 Millimeters and The Height IS 210 Millimeters.

THE TOP, BOTTOM, LEFT, AND RIGHT Margins of The Page Are All 1 Centimeter.

The Body Has A 3 Centimeter Margin (On All Side).

The Before, After, Start, And End Regions (of The Body) Are All 2 Centimeters.

The Width of the Body In The Example Above Can Be Calculated by Subtracting The Left And Right Margins and The Region-Body Margins from The Width of The PageTself:

297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm.

Note That The Regions (Region-Start and Region-End) Are Not a Part of The Calculation. AS Described Earlier, These Regions Are Parts of the Body.

XSL-FO Blocks

XSL-FO OUTPUT GoES INTO Blocks.

XSL-FO PAGES, FLOW, AND BLOCK

"Blocks" of content "flow" INTO "Pages" of the output media.

XSL-FO OUTPUT IS NORMALLY NESTED INSISIDE Elements, Nested Inside Elements, Nested Inside Elements:

Block Area Attributes

Blocks Are SEQUENCES OF OUTPUT in Rectangular Boxes:

Border-width = "1mm">

This Block of Output Will Have A One Millimeter Border Around IT.

Since Block Areas Are Rectangular Boxes, They Share Many Common Area Properties:

Space Before and Space After Margin Border PaddingSpace Before

margin

Border

Padding

Content

SpaceAfter

............... ..

The margin is the empty area on the outside of the block.

The Border Is The Rectangle Drawn Around The External Edge of The Area. It Can Have DiffERENT WIDTHS ON All Four Side. It can Also Be Filled With Different Colors and Background Images.

The Padding is The area between the border and the content area.

The Content Area Contains The Actual Content Like Text, Pictures, Graphics, or Whatever.

Block margin

Margin Margin-Top Margin-bottom Margin-Left Margin-Right

Block border

Border Style Attributes:

Border-style border-based-style border-start-style border-endle border-top-style (Same as border-before) border-bottom-style (Same as border -After) border-left -style (Same as border-start) border-right-style (Same as border-end)

Border Color Attributes:

Border-color border-before-color border-instry-color border-start-color border-end-color border-top-color (Same as border-before) border-bottom-color (Same as border -Arth) Border-Left -COLOR (Same as Border-Start) Border-Right-Color (Same as Border-End)

Border Width Attributes:

Border-width Border-Width Border-start-width Border-end-width border-top-width (Same as border-before) border-bottom-width Border-left -width (Same as border-start) border-right-width (Same as border-end)

Block Padding

padding padding-before padding-after padding-start padding-end padding-top (same as padding-before) padding-bottom (same as padding-after) padding-left (same as padding-start) padding-right (same as padding -end) Block Background

Background-color background-image background-repeat background-attachment (scroll or fixed)

Block Styling Attributes

Blocks Are SEQUENCES OF OUTPUT THAT CAN BE STYLED Individally:

Font-size = "12pt"

Font-family = "Sans-Serif">

This Block of Output Will BE Written In A 12pt Sans-Serif Font.

Font Attributes:

Font-Family Font-Weight Font-Style Font-Size Font-Variant

Text Attributes:

text-align text-align-last text-indent start-indent end-indent wrap-option (defines word wrap) break-before (defines page breaks) break-after (defines page breaks) reference-orientation (defines text rotation in 90 "increments)

EXAMPLE

Font-size = "14pt" font-family = "verdana" font-color = "red"

Space-before = "5mm" Space -After = "5mm">

W3Schools

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.

RESULT:

W3Schools At W3Schools you will find all the web-building tutorials you need, from Basic HTML and XHTML to Advanced XML, XSL, MultiMedia and WAP.

WHEN You Look at The Example Above, you can see it.

Normally XSL-FO Document Do Not Combine Formatting Information and Content Like We Have Done Here.

. L.

You Will Learn More About How To Combine XSL-Fo with xslt Templates in a Later Chapter in this Tutorial.

XSL-FO LISTS

XSL-FO Uses List Blocks to Define Lists.

XSL-FO List Blocks

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 - type " Number, Character, ETC.) FO: List-item-body (contains the content / body of the list-item - typical one or more Objects)

An XSL-FO LIST EXAMPLE:

*

Volvo

*

saab

The Output from this Code Would Be:

* Volvo * Saab

XSL-FO TABLES

XSL-FO Uses The Element to Define Tables.

XSL-FO TABLES

The xsl-fo Table Model Is Not Very Different from The HTML Table Model.

There Are Nine XSL-FO Objects Used to Create Tables:

FO: TABLE-Column Fo: Table-Header Fo: Table-Footer Fo: Table-Cell

XSL-FO Uses The Element to Define a Table. It Contains a and an optional Element.The Element Contains Optional Elements, An Optional Element, A Element, And An Optional Element. Each of these elements HAS One or more Elements, with one or more Elements:

car

Price

Volvo

$ 50000

saab

$ 48000

The Output from this Code Would Something Like this:

Carpricevolvo $ 50000SAAB $ 48000

XSL-fo and xslt

XSL-fo and xslt can help each other.

REMEMBER THIS EXAMPLE?

Font-size = "14pt" font-family = "verdana" font-color = "red"

Space-before = "5mm" Space -After = "5mm"> W3Schools

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.

RESULT:

W3Schools At W3Schools you will find all the web-building tutorials you need, from Basic HTML and XHTML to Advanced XML, XSL, MultiMedia and WAP.

The Example Above Is from The Chapter About Xsl-fo Blocks.

With a little help from xslt

Remove the xsl-fo information from the document:

W3Schools

AT W3Schools you will find all the web-building tutorials you

Need, from Basic HTML and XHTML to Advanced XML, XSL, MultiMedia

And WAP.

Add an Xslt Transformation:

Font-size = "14pt" font-family = "verdana" font-color = "red"

Space-before = "5mm" Space -After = "5mm">

Text-indent = "5mm"

Font-family = "verdana" font-size = "12pt"

Space-before = "5mm" Space -After = "5mm">

And The Result Will Be The Same:

W3Schools At W3Schools you will find all the web-building tutorials you need, from Basic HTML and XHTML to Advanced XML, XSL, MultiMedia and WAP.

XSL-FO Software

XSL-FO Needs Formatting Software to Produce Output.

XSL-FO Processors

An XSL-FO Processor is a Software Program for Formatting XSL Documents for Output.

Most XSL-FO Processors Can Output PDF Document, And Quality Print As Well AS HTML AND Other Formats.

Here is a list of the most mark xsl-fo processors:

XSL Formatter

XSL Formatter is a Software to Format XML Documents for Production-Quality Printing and Output to PDF.

Antenna House has been providing version V2 of the same product since January, 2002 in the global market, and XSL Formatter was rated as one of the best quality product at the XML 2002, XML 2003 conferences held in Europe.

Building on over 4 years of experience developing XSL-FO software, Antenna House has completely written from scratch an entirely new Formatter that offers significant enhancements and provides a solid foundation on which to continue to move forward.

Visit Antenna House

Xinc Beta Release

XINC IS An Xsl-Fo Processor by Lunasil Ltd.

Xinc is designed to be fast, multithreaded and memory efficient. A Swing based XSL-FO viewer allows you to view and print XSL-FO files as well as generate PDF files with the click of a button. Xinc can be used as a server component via its Java API. Xinc can also be used in a Microsoft server environment by using its COM interface. New features include hyphenation, basic-link, PDF output, memory / speed optimizations and a simple COM interface.

Visit Lunasil Ltd

Scriptura

Inventive Designers Scriptura IS A Cross-Platform Document Design and Generation Solution Based on Xslt and XSL-FO.

Scriptura has a WYSIWYG design tool and engine The XSL-FO formatter used in the engine is no longer based on Apache FOP, but is written from scratch by Inventive Designers The new features in this release are:.. Support for bulleted and numbered lists, 'Break-Before' and 'Break -After' Properties, Extended Bar Code Options and Improved Number and currency formatting. a free trial version is available for Download.Visit Inventive Designers

转载请注明原文地址:https://www.9cbs.com/read-67096.html

New Post(0)