Home > Online Product Documentation > Table of Contents > Generating Formatting Objects
You can use Stylus Studio to develop a stylesheet that generates XSL Formatting Objects (FO). In the scenario in which you apply such a stylesheet, you can specify that Stylus Studio should run a Formatting Objects Processor (FOP) on the stylesheet's result document. When you apply the stylesheet and preview the results, Stylus Studio displays the formatted results.
Stylus Studio includes The Apache Software Organization's FOP, and it is configured to always generate PDF. If you want to run a FOP to generate some other type of output, you must specify some other FOP in the Custom post-process fields of the Post-process tab of the Scenario Properties dialog box.
Stylus Studio includes two sample stylesheets that generate formatting objects. These files are in the
examples\XSLFormattingObjects directory of your Stylus Studio installation directory.
This section covers the following topics:
|
Note
|
|
FO is a W3C recommendation for an XML vocabulary that describes how to format text. FO is one part of XSL. This section assumes that you are familiar with FO. For additional information about FO, see http://www.w3.org/TR/2001/REC-xsl-20011015/. |
The Apache FOP included with Stylus Studio is configured to convert FO XML into PDF. Stylus Studio then uses Acrobat Reader to display the PDF in the Stylus Studio preview window.
<fo:, Stylus Studio displays a completion menu of FO that you can select from.
After Stylus Studio transforms the XML document to generate a result XML document that contains formatting objects, Stylus Studio automatically runs the FOP you specified on the result document. Stylus Studio then displays the postprocess result in the XSLT Preview window.
If the transformation works well, but the FOP generates an error, obtain a copy of RenderX's Unofficial DTD for XSL Formatting Objects. You can find this at http://www.renderx.com. Although this DTD is not official (it is more limited than what the W3C XSL recommendation defines), it is a helpful debugging tool.
C:\fo.dtd.
examples\XSLFormattingObjects\minimal-catalog.xsl file in your Stylus Studio installation directory.
Alternative: If the Stylus Studio
examples project is open, you can access this file from the
Project window. To open the
examples project, open
examples.prj in the Stylus Studio
examples directory.
The
video scenario has already been defined. In the
Post-process tab of the
Scenario Properties dialog box,
Postprocess with Apache FOP is selected.
In this scenario, Stylus Studio selects elements to operate on from three different documents. These documents are in the
examples directory of the Stylus Studio installation directory. They are also in the
examples project. The documents are:
After a few seconds, the Preview window displays the PDF result in Acrobat Reader. The result contains a few lines of text for each video and book found in the XML source documents. The title, author or director, and the description is included for each item. It is hard to see where information for one item ends and another begins.
examples\XSLFormattingObjects\catalog.xsl stylesheet.
This time the PDF result in the
Preview window is nicely formatted. The
catalog.xsl stylesheet adds some basic formatting, as well as images, to the
minimal-catalog.xsl stylesheet. Now it is easy to distinguish the title, author or director, and description for each video or book.
When your stylesheet is complete, the process for creating a final document, such as a PDF document, from an XML document is as follows:
You can accomplish both steps with a single invocation of FOP on the command line. For example:
Replace
C:\Program Files\StylusStudio with the name of the directory in which Stylus Studio is installed.
The Apache FOP included with Stylus Studio is configured to output PDF.
Modify this sample command line according to where Stylus Studio is installed and what kind of output you want the FOP to generate. The last option,
-svg in the example, can be any of the following:
|
Setting
|
Output
|
|---|---|
-mif
|
MIF file
|
-pcl
|
PCL file
|
-txt
|
Text file
|
-svg
|
SVG slides file
|
-at
|
XML (representation of an area tree)
|
-pdf
|
PDF file
|
.txt if you want the FOP to generate a text file.