What is XSL-FO?
- XSL-FO is a language for 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
- XSLT, a language for transforming XML documents
- XSL or XSL-FO, a language for formatting XML documents
- XPath, a language for navigating through elements and attributes in XML documents
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 file extension. It is also quite common to see XSL-FO documents stored with an .xml extension, because this makes them more accessible to XML editors.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<!-- Page template goes here -->
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<!-- Page content goes here -->
</fo:page-sequence>
</fo:root>
XSL-FO Pages
XSL-FO Regions
XSL-FO Block Areas
XSL-FO Line Areas
XSL-FO Inline Areas
XSL-FO Page, Flow, and Block
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello W3Schools</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
XSL-FO Page Margins
XSL-FO Page Regions
page-width="297mm" page-height="210mm"
margin-top="1cm" margin-bottom="1cm"
margin-left="1cm" margin-right="1cm">
<fo:region-body margin="3cm"/>
<fo:region-before extent="2cm"/>
<fo:region-after extent="2cm"/>
<fo:region-start extent="2cm"/>
<fo:region-end extent="2cm"/>
</fo:simple-page-master>
Block Margin
Block Border
Block Padding
Block Background
Block Styling Attributes
font-size="14pt" font-family="verdana" color="red"
space-before="5mm" space-after="5mm">
W3Schools
</fo:block>
<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.
</fo:block>
XSL-FO Tables
XSL Formatting Objects Reference
The process that converts a description into a presentation is called formatting.
| Object | Description |
| basic-link | Represents the start resource of a link |
| bidi-override | Overrides the default Unicode BIDI direction |
| block | Defines a block of output (e.g. paragraphs and titles) |
| block-container | Defines a block-level reference-area |
| character | Specifies a character that will be mapped to a glyph for presentation |
| color-profile | Defines a color-profile for a stylesheet |
| conditional-page-master-reference | Specifies a page-master to be used when the conditions defined are true |
| declarations | Groups global declarations for a stylesheet |
| external-graphic | Used for a graphic where the graphics data resides outside of the XML result tree |
| float | Typically used to position an image in a separate area at the beginning of a page OR to position an image to one side, with the content flowing along-side of the image |
| flow | Contains all elements to be printed to a page |
| footnote | Defines a footnote within the region-body of a page |
| footnote-body | Defines the content of the footnote |
| initial-property-set | Formats the first line of an <fo:block> |
| inline | Formats a part of a text with a background or enclosing it in a border |
| inline-container | Defines an inline reference-area |
| instream-foreign-object | Used for inline graphics or for "generic" objects where the object's data resides as descendants of <fo:instream-foreign-object> |
| layout-master-set | Holds all masters used in a document |
| leader |
Used to generate "." to separate titles from page numbers in table of contents, or to create input fields in forms, or to create horizontal rules |
| list-block | Defines a list |
| list-item | Contains each item in the list |
| list-item-body | Contains the content/body of the list-item |
| list-item-label | Contains the label for the list-item (typically a number, character, etc.) |
| marker | Used with <fo:retrieve-marker> to create running headers or footers |
| multi-case |
Contains (within an <fo:multi-switch>) each alternative sub-tree of XSL-FO objects. The parent <fo:multi-switch> will choose which alternative to show and hide the rest |
| multi-properties | Used to switch between two or more property-sets |
| multi-property-set | Specifies an alternative property-set that will be applied depending on the state of the user agent |
| multi-switch | Holds one or more <fo:multi-case> objects and controls the switching between them (activated by <fo:multi-toggle>) |
| multi-toggle | Used to switch to another <fo:multi-case> |
| page-number | Represents the current page-number |
| page-number-citation | References the page-number for the page that contains the first normal area returned by the cited object |
| page-sequence | A container for page output elements. There will be one <fo:page-sequence> object for each page layout |
| page-sequence-master | Specifies which simple-page-masters are to be used and in which order |
| region-after | Defines a page footer |
| region-before | Defines a page header |
| region-body | Defines a page body |
| region-end | Defines the right sidebar of a page |
| region-start | Defines the left sidebar of a page |
| repeatable-page-master-alternatives | Specifies repetition of a set of simple-page-masters |
| repeatable-page-master-reference | Specifies repetition of a single simple-page-master |
| retrieve-marker | Used with <fo:marker> to create running headers or footers |
| root | The root (top) node for XSL-FO documents |
| simple-page-master | Defines the size and shape of a page |
| single-page-master-reference | Specifies a page-master to be used at a given point in the sequence of pages |
| static-content | Contains static content (e.g. headers and footers) that will be repeated on many pages |
| table | Formats the tabular material of a table |
| table-and-caption | Formats a table and its caption |
| table-body | Container for table rows and table cells |
| table-caption | Contains the caption for a table |
| table-cell | Defines a table cell |
| table-column | Formats the columns of a table |
| table-footer | Defines a table footer |
| table-header | Defines a table header |
| table-row | Defines a table row |
| title | Defines a title for a page-sequence |
| wrapper | Specifies inherited properties for a group of XSL-FO objects |
* Reference to W3C Schools
浙公网安备 33010602011771号