Extensible Stylesheet Language - Formatting Objects

from Wikipedia, the free encyclopedia

XSL-FO ( Extensible Stylesheet Language - Formatting Objects ) is an XML application that describes how text, images, lines and other graphic elements are arranged on a page. With XSL-FO you can format documents not only for display on screens, but also for high-quality printed products on paper. With XSL-FO, documents can even be formatted for reading aloud using a speech synthesizer.

XSL-FO is part of the W3C's XSL specification .

properties

XSL-FO is a descriptive markup language that has its roots in DSSSL and was developed in parallel with CSS at times . The decisive differences between XSL-FO and CSS are the page model ( areas in XSL-FO, box model in CSS) and the process model (two-stage processing using XSLT and then the layout with XSL-FO formatters on the one hand and the ad- hoc formatting with CSS renderers on the other hand). XSL-FO contains elements and attributes for the following aspects:

  • Regions, margins and areas of a page,
  • Width and height of pages,
  • Sequence of pages,
  • Pagination,
  • Frames, spaces, columns and blocks,
  • Paragraphs, lists and tables,
  • Text formatting such as sentence formats and separation,
  • Lines, pictures and other objects
  • and much more.

The list is far from complete, especially with regard to XSL 1.1.

XSL-FO was not developed for word processing, but for professional printing, which is why the range of functions of these two technologies is difficult to compare. However, if you add XSLT as a transformation language to XSL-FO, many functions of today's word processing systems can be simulated with the two languages. You have a language for representation (through XSL-FO) and processing logic (XSLT); word processing systems usually combine both areas of responsibility in one language and in one place.

So-called FO processors are available for generating PDF , RTF , ASCII text and other print media from an XSL-FO file . A widely used program is FOP (Formatting Objects Processor) from the Apache project (see web link), a Java application that generates PDF documents from XSL-FO data and also partially supports Postscript and PCL . For .NET developments there is a very restricted NFop port of the Java project, which only supports the PDF output format. In many branches of industry, however, commercial formatters are used which on the one hand support larger parts of the specification and on the other hand also contain their own extensions that are not part of XSL-FO but are absolutely necessary for practical use, e.g. B. other output formats.

method

Transformation of XML data into an FO tree and into a PDF document, schematic representation

The starting point is an XML document that is converted into an XSL-FO file using XSLT stylesheets. The XSLT stylesheet selects the required elements from the original document and transforms them into a combination of XSL-FO elements and attributes (the FO tree ). These determine the appearance in the target medium (e.g. page design, design of columns, lists, tables, etc.). This process is repeated until the original document has been completely processed. In a second step, a suitable formatter (also known as an FO processor) creates the desired target file (e.g. PDF, RTF or PostScript).

example

The following example defines an A4 page with the text Hallo Welt!:

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <fo:layout-master-set>
    <fo:simple-page-master  master-name="myA4page"
                            page-width="210mm" page-height="297mm">
      <fo:region-body region-name="xsl-region-body"  margin="2cm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence  master-reference="myA4page">   <!-- (in Versionen < 2.0 "master-name") -->
    <fo:flow flow-name="xsl-region-body">
      <fo:block>Hallo Welt!</fo:block>
    </fo:flow>
  </fo:page-sequence>

</fo:root>

literature

Web links