Einleitung
XSL-FO Sprachelemente
XHTML nach FO nach PDF
Darstellung von Online- und Druck-Dokumenten sowie Sprachausgabe.
Spezifikation der grundlegenden Elemente, ohne die Details einer Implementierung festzulegen.
Der XSL-FO Verarbeitungsprozess (Quelle W3C)
Der Verarbeitungsprozess verläuft intern durch verschiedene Verfeinerungen
von fo:
-Bäumen über object/property
-Bäumen
zu object/traits
-Bäumen.
Die Letzteren können dann direkt auf dem Ausgabemedium dargestellt werden.
fo:block
, fo:inline
mit Eigenschaften (properties), die CSS2 entsprechen.
fo:layout-master-set
, fo:simple-page-master
fo:region-body
oder ähnliche Dinge für Bildschirmausgabe oder Sprachausgabe
fo:page-sequence master-reference="seite"
,
fo:static-content
,
fo:flow flow-name="body"
Als Namensraum wird in diesem Abschnitt immer
fo:
mit dem URL
http://www.w3.org/1999/XSL/Format
verwendet.
Das Root-Element ist immer fo:root
.
Formatierung durch areas, die eine Erweiterung des Box-Modells von CSS (block oder inline) sind. U.A. können auch Zwischenräume spaces genauer definiert werden sowie Nebenbedingungen (constraints) für die Anordnung der Areas.
XSL-FO Area Rechtecke (Quelle W3C)
fo:block
Formatierung eines Blocks mit diversen Attributen
fo:character
Formatierung eines Zeichens mit diversen Attributen
fo:inline
Formatierung einer Zeichenfolge mit diversen Attributen
innerhalb eines fo:block
fo:basic-link
Formatierung eines A-Links mit internen und externen Referenzen
fo:external-graphic
Formatierung einer Grafik (z.B. GIF-Image) mit diversen Attributen
fo:list-block
und fo:list-item
für die Formatierung einer Liste von Blocks und Listen-Items
mit diversen Attributen
Formatierung von Tabellen mit diversen Attributen
fo:table
,
fo:table-row
,
fo:table-cell
,
fo:table-column
,
fo:table-body
, ...
Die CSS2 Atribute sind zum Teil weiter ausdifferenziert.
font-family="sans-serif"
Attribut für Schriftart
font-style="italic"
Attribut für Schriftstil
color="red"
Attribut für Schriftfarbe
background-color="aqua"
Attribut für Hintergrundfarbe
text-align="center"
Attribut für Textausrichtung
space-before="8pt" space-after="4pt"
Attribute für Leerraum vor bzw. hinter einem Block
break-before="page"
Attribut, das einen Seitenumbruch anstösst
external-destination="url('{@href}')"
Verweis auf einen externen URL (in fo:basic-link
)
src="url('{@src}')"
Verweis auf eine externe Grafik (in fo:external-graphic
)
column-width="5cm"
Breite einer Tabellenspalte (in fo:table-column
).
Zur Zeit gibt es in FOP (0.20.5) noch keine automatische
Tabellengrössenbestimmung.
Hier nur für Druck/PDF-Ausgabe betrachtet.
Die Definitionen umfassen im Wesentlichen die Breite und Höhe, sowie die verschiedenen Ränder.
XSL-FO Seitenbereiche (Quelle W3C)
fo:layout-master-set
definiert alle Seitenvorlagen,
die in dem Dokument verwendet werden.
fo:simple-page-master
definiert eine einfache Seitenvorlage,
die alles wesentliche für eine Druckseite und
die Regionen einer Druckseite definieren kann.
fo:region-body region-name="koerper"
,
fo:region-before
,
fo:region-after
,
fo:region-start
,
fo:region-end
definiert die Regionen, die in einer Druckseite auftreten können.
(Vergleichbar mit den Frames in HTML)
Wie werden die Darstellungselemente (z.B. fo:block
)
in die Ausgaberegionen eingefüllt, bzw. wie fliessen diese in die
Ausgaberegionen?
fo:page-sequence master-reference="seite"
definiert eine Folge von Seiten, die ein bestimmtes
Masterlayout (z.B. fo:simple-page-master
)
verwenden und die Füllung der Seitenregionen.
fo:static-content flow-name="bottom"
definiert statischen Inhalt, also Inhalt der sich auf
jeder Seite wiederholt, für eine bestimmte Ausgaberegion
(flow-name
)
fo:flow flow-name="body"
definiert dynamischen Inhalt, also den veränderlichen Inhalt
der Seiten, für eine bestimmte Ausgaberegion
(flow-name
)
von den Apache FOP Beispielen:
<?xml version="1.0" encoding="utf-8"?> <!-- example for a simple fo file. At the beginning the page layout is set. Below fo:root there is always - a single fo:layout-master-set which defines one or more page layouts - an optional fo:declarations - and a sequence of one or more fo:page-sequences containing the text and formatting instructions --> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <!-- fo:layout-master-set defines in its children the page layout: the pagination and layout specifications - page-masters: have the role of describing the intended subdivisions of a page and the geometry of these subdivisions In this case there is only a simple-page-master which defines the layout for all pages of the text --> <!-- layout information --> <fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm"> <fo:region-body margin-top="3cm" margin-bottom="1.5cm"/> <fo:region-before extent="3cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <!-- end: defines page layout --> <!-- start page-sequence here comes the text (contained in flow objects) the page-sequence can contain different fo:flows the attribute value of master-name refers to the page layout which is to be used to layout the text contained in this page-sequence--> <fo:page-sequence master-reference="simple"> <!-- start fo:flow each flow is targeted at one (and only one) of the following: xsl-region-body (usually: normal text) xsl-region-before (usually: header) xsl-region-after (usually: footer) xsl-region-start (usually: left margin) xsl-region-end (usually: right margin) ['usually' applies here to languages with left-right and top-down writing direction like English] in this case there is only one target: xsl-region-body --> <fo:flow flow-name="xsl-region-body"> <!-- each paragraph is encapsulated in a block element the attributes of the block define font-family and size, line-heigth etc. --> <!-- this defines a title --> <fo:block font-size="18pt" font-family="sans-serif" line-height="24pt" space-after.optimum="15pt" background-color="blue" color="white" text-align="center" padding-top="3pt"> Extensible Markup Language (XML) 1.0 </fo:block> <!-- this defines normal text --> <fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="3pt" text-align="justify"> The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML has been designed for ease of implementation and for interoperability with both SGML and HTML. </fo:block> ... </fo:flow> <!-- closes the flow element--> </fo:page-sequence> <!-- closes the page-sequence --> </fo:root>
Ergebnis als PDF.
Es existieren verschiedene Softwarepakete, die XSL-FO verarbeiten können.
Bietet Konversion von XSL-FO Dateien nach PDF. Kann auch den Vorbereitungsschritt mit XSLT nach XSL-FO mit übernehmen.
Apache FOP AWT-Vorschau
Optionen:
./fop.sh USAGE Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-ps|-txt|- at|-print] <outfile> [OPTIONS] -d debug mode -x dump configuration settings -q quiet mode -c cfg.xml use additional configuration file cfg.xml -l lang the language to use for user information -s for area tree XML, down to block areas only [INPUT] infile xsl:fo input file (the same as the next) -fo infile xsl:fo input file -xml infile xml input file, must be used together with -xsl -xsl stylesheet xslt stylesheet [OUTPUT] outfile input will be rendered as pdf file into outfile -pdf outfile input will be rendered as pdf file (outfile req'd) -awt input will be displayed on screen -mif outfile input will be rendered as mif file (outfile req'd) -pcl outfile input will be rendered as pcl file (outfile req'd) -ps outfile input will be rendered as PostScript file (outfile req'd) -txt outfile input will be rendered as text file (outfile req'd) -txt.encoding encoding use the encoding for the output file. the encoding must be a valid java encoding. -svg outfile input will be rendered as an svg slides file (outfile req'd) -at outfile representation of area tree as XML (outfile req'd) -print input file will be rendered and sent to the printer see options with "-print help" [Examples] Fop foo.fo foo.pdf Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line) Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf Fop foo.fo -mif foo.mif Fop foo.fo -print or Fop -print foo.fo Fop foo.fo -awt
Ein Beispiel für die Transformation von XHTML nach XSL-FO für den FO-Processor FOP von Apache.org.
Eine Alternative mit mehr Funktionen bietet der Antennahouse XSL Formater AXF.
Die Haupttexte der Vorlesung als PDF.
© Universität Mannheim, Rechenzentrum, 1998-2005.
Heinz KredelLast modified: Sat Apr 9 11:53:54 CEST 2005