FOA: an XSL-FO Authoring Tool

Fabio Giannetti
Fabio_Giannetti@hp.com

Abstract

FOA [Formatting Object Authoring] is an open-source authoring tool that applies rich styling to XML content. It allows the styling to be re-used across multiple documents. It also allows the author to build or import a library of style components. It is based on XSL-FO, the W3C-defined markup language, whose aim is to add rich styling to XML content, especially for paginated documents.

The architecture of FOA permits the author to create and modify style sets, and also allows these styles to be re-applied to different XML content. The tool generates an XSL stylesheet, based on the style information It takes the XML content and produces an XSL-FO document, which can then be rendered into different output formats. An extension to an XSL-FO renderer allows the author to preview the output within the authoring tool.

Keywords: XSL-FO; Editing/Authoring

Fabio Giannetti

Fabio Giannetti: MSc Computer Science Engineering (University of Genoa, Italy) in July 2000, thesis entitled "XML and XSL for document management and rendering". Joined Hewlett-Packard Laboratories (Bristol, UK) in August 2000, initially developed WH2FO (Word HTML 2 Formatting Objects) and FOA (Formatting Object Authoring tool), using XSL-FO technology. Currently investigating how XML and XSL technology could be used to publish web applications and content in a device independent manner.

FOA: an XSL-FO Authoring Tool

Fabio Giannetti [Hewlett Packard Laboratories]

Extreme Markup Languages 2002® (Montréal, Québec)

Copyright © 2002 Fabio Giannetti. Reproduced with permission.

Introduction

The separation of content, expressed in application-specific XML-based dialects, from presentation is now well established. There are plenty of tools that allow authors to create XML documents, defining their own tags, DTDs [Document Type Definition] and Schemas. The addition of appropriate semantic tags to the content gives a much greater chance that the content can be reused, including for different presentation purposes.

An XML document presents a well-defined structure and this will help authoring tools to create a simpler way to style it. There is a mature literature on formatting and rendering structured documents [1] as well as mature tools such as Scribe [2] and LaTeX [3].

Most of these tools already introduce the concept of an interactive methodology to style documents and there are already commercial products and projects.

Of course, an XML document requires a presentation to be defined before it can be rendered and made easily readable to users. So far, most authoring tools and editors, based on XSL-T, focus their attention on transforming documents for presentation using web delivery markup languages such as HTML or WML. These are relatively simple formats compared to the richness of presentation available on printed pages.

The main focus is to create an interactive authoring environment in which the author can use familiar paradigms to transform and style his or her XML content. In order to do this, FOA [4] will use two re-usable components, one to define the transformation and one to apply the desired style.

Until now, paginated documents for web delivery have been authored mainly using conventional word processing tools. Adobe's PDF is often used as a delivery format because it preserves the appearance of the document and provides good quality when it is printed. However, this approach assumes that the content is re-authored specifically for printing.

To give authors the ability to create complex documents without involving programming effort an XSL style-sheet must be created using a user-friendly tool. These tools help authors to style their documents, maintaining the separation between semantic content, transformation processes and styling of the document. FOA is intended to provide such support.

Our authoring tool accelerates the style creation, in a rich paginated form, for XML-based documents that need to be delivered using page description languages such as PDF and/or PCL. Web authoring tools can hide the complexities of styling markup from authors. For example, today it is possible to write HTML documents without knowing anything about CSS [Cascading Style Sheets], simply using WYSIWYG tools. However, the styling complexity required to express rich paginated layout is considerably more difficult than that used in HTML.

The FOA authoring tool sets out to provide an improved authoring environment for styling XML documents using XSL-FO styling markup. It gives authors a better way to style their documents, maintaining the separation between content and style and making the transformation stylesheets reusable as much as possible.

FOA has been cited on the W3C Document Formats Domain [5] as the first available XSL Authoring tool.

Creating documents using XSL-FO

XSL [Extensible Stylesheet Language] [6] is a W3C standard that consists of two parts, a transformation language called XSLT [7] and a presentation markup language usually called XSL-FO or simply FO [8]. XSL-FO, a W3C Recommendation, defines an object-based presentation markup language, independent from any platform or user agent implementation, that can be used to add rich styling to XML content.

Given an arbitrarily structured XML document, an author can use an XSL stylesheet to express how the content should be presented [9]. The presentational part of the stylesheet expresses the way in which the document will be styled, laid out and paginated onto some presentation medium or a set of physical pages.

Processing a stylesheet involves two steps, first to transform and add styling information to the document, and then render it into a suitable delivery format. The first step is normally performed using an XSLT processor that transforms the XML content according to the XSL stylesheet into a target presentation markup language. Next, a rendering engine interprets the presentation markup to make it viewable. For instance, a web browser such as Microsoft's Internet Explorer can invoke an XSLT processor to transform XML into HTML according to an XSL stylesheet. The browser itself includes an embedded rendering engine to render the HTML as a web page [10].

In our case the target language is designed to render the document onto paginated media and usually involves a richer set of styling information. This presentation markup language is XSL-FO. The XSL-FO markup is added by the XSLT processor [11] [12] during the XSL stylesheet transformation. Figure 1 shows the two-step process to obtain a final rendered document in a deliverable page description language.

Figure 1: Two-step process: transform and render
[Link to open this graphic in a separate page]

XSL-FO Formatting Objects provide an output-independent way to express document layout. When the XSL-FO file is parsed by the rendering engine it will be translated into an internal area-based model that positions each presentation element in the correct relative position. The internal representation of the area-based document can then be transformed into a page description language converting each area, with its associated traits, into the corresponding output notation. The area representation gives the rendering engine the ability to create multiple formats, starting from the same document description. This is an advantage for the delivery of documents across multiple platforms and devices.

To achieve this goal the document author must write an XSL stylesheet that transforms an XML document into an XSL-FO document, and defines how the appropriate styling is applied for each XML tag or group of tags. The transformation part of a stylesheet has all the power of a programming language. In fact, the author must know concepts, such as tree manipulation, that are more familiar to a programmer than an author/designer.

The FOA authoring tool

FOA is an open-source authoring tool that helps authors/designers to give a layout and style to their XML content. FOA is not a WYSIWYG editor but using a consistent preview and a property manager it can give feedback which is sufficient to indicate the final results. FOA is intended to style documents that are expressed in XML and may have even been generated automatically.

FOA creates an XSLT file that, when applied to the XML using an XSLT processor, generates the appropriate XSL-FO. In addition, FOA stores the style attributes in one or more separate XSL files, so the author can re-use them for processing other XML documents.

Figure 2 shows the FOA functional context. In particular, it shows how multiple XML source documents may be used to compose the final XSL-FO document and how multiple style attribute sets can be combined to generate the correct transformations.

Figure 2: FOA functional context
[Link to open this graphic in a separate page]

Figure 3 shows an overview of the application. In this picture there is a synthesis of all the application components, called "Managers", involved in the authoring process.

Figure 3: FOA overview
[Link to open this graphic in a separate page]

Each Manager works on different aspects of the authoring process; there are six different Managers as follows:

  1. Page Manager: is responsible for page geometry. It allows the user to generate pages with all FO properties such as dimensions and margins. This manager is also responsible for the creation of page regions. The FO specification defines a page with a maximum of 5 regions which are usually header, body, footer, left side and right side;
  2. Page Sequence Manager: is responsible for the creation of page sequences as defined in XSL-FO. A simple example of a sequence is a facing page sequence in which the odd page and the even page have different margins to facilitate binding;
  3. Attribute Set Manager: it is responsible for the Attribute Sets allowing their own creation and editing;
  4. XML Content Manager: is responsible for the import of an XML content file and its display as a tree. The author can select the content amount to load within the application varying from the structure to the full document;
  5. Brick Manager: is responsible for the creation, modification and deletion of Bricks (see section 4). There are several Brick trees identified by a group. Each group will generate a different family of Bricks in which there can be sub-groups called "types" (e.g. Ordered List or Unordered List are "types" of the List group);
  6. Content Sequence Manager: is responsible for defining which pieces of content will be put into the various regions available in the sequence. Basically the author will define the content sequences to process, using the defined Bricks, inside the regions. Of course the author can define different entries from different XML files and select a particular tag or a sequence of tags.

When an author creates a new XSLT project or opens an existing one, FOA will automatically open the related Attribute Set(s) and the related XML content file(s). At this point the author can use all the Managers to create/refine the authoring process. When the authoring is completed, FOA will save a new XSLT project file that includes all the Attribute Sets actually used, and will point to the XML content involved in the transformation process.

There are several different situations in which FOA can help authors format XML content with XSL-FO:

  • to create new transformations and layout styles for some XML content; in this case, the author will create a new XSLT which takes the XML content and transforms it into a new XSL-FO document with the newly defined styles
  • to create new transformations in order to apply styles developed for one piece of XML content to a different piece of XML content; in this case, the author can re-use the Attribute Sets previously created and associate them to different XML content which may use different tags from the original
  • to re-use an existing transformation by modifying or adding new styles; in this case, some existing XML content will be re-styled by changing the style information only

To achieve these results FOA uses two paradigms, a fundamental transformation element called a "Brick" and a set of properties to apply to the transformed content called an "Attribute Set". In the next sections we will explain the approach taken to give the necessary independence to the transformation and the styling parts.

A re-usable transformation component: "Brick"

As already mentioned, many authors will prefer a re-usable and reliable way to create a transformation stylesheet without needing to learn the details of the transformation language.

To achieve this, FOA introduces the concept of a re-usable transformation component called a "Brick". Each Brick is used to apply styling to a well-defined component of the XML document. There will be a Brick that represents a text block, or an image or a table and so on. As part of each Brick, there is some XSLT code that transforms the XML content into the appropriate set of Formatting Objects.

Some Bricks are very simple while others can be very complicated (e.g. for tables), but the author does not have to worry about the details since FOA will create the necessary XSLT transformations to achieve the results. The only action that the author must perform is to relate the content to the style. In complex cases, such as lists, FOA will ask the author to relate more than a single tag to the style, and sometimes it will automatically import a content sub-tree.

The Bricks are subdivided into groups. When the author chooses to create a block of text, firstly he will ask the application to create the corresponding object in the FO space: a <fo:block>. Secondly, the author will choose a defined style from those that apply to that block. This subdivision helps the author to choose a suitable set of style attributes that can be applied to the content and also can provide a series of hints explaining the effects caused by the chosen attributes.

Figure 4: A simple Brick
      <xsl:template match=path  foa:name=label foa:group=group foa:class=class>
        <fo:element foa:name=label foa:group=group  xsl:use-attribute-sets=label>
          <xsl:apply-templates/>
              </fo:element>
      </xsl:template>
    

Figure 4 shows the basic architecture of a Brick. It is composed of a standard XSLT template, including an XPath match on XML content. Some special attributes like foa:name, foa:group and foa:class specify the Brick label, the group and the kind of FO that will be created by the transformation process. All this "extra" information is necessary to re-open the XSL project file and re-construct the Brick trees. The foa:class attribute creates a relationship between the brick and the FO, that helps the author to select between ranges of properties applicable to that specific FO. For example, an <fo:block> element will have different properties from an <fo:list>.

As we can notice from the example, the FO element itself contains some Brick information, this is necessary to give to FOA the ability to retrieve the Brick from the preview window giving to the author a powerful instrument to see the rendering result of a particular Brick and/or visualize the subject of possible changes. Figure 5 describes how a Brick will be filled in by FOA:

Figure 5: How FOA fills a Brick
[Link to open this graphic in a separate page]

The author will select from the Brick Manager window a group, which is a logical subdivision of the Bricks, e.g. paragraph, list, emphasis, etc. FOA will show a tree of the currently defined Bricks in that group and allow the user to create, modify or delete one of them. When a new Brick is created the author will fill it taking information from the other involved managers. So, for example, as well as giving to the Brick a name, he will select a matching tag directly from the Content Manager and an Attribute Set from the currently available. The author can, as the same of Bricks, generate, modify and delete Attribute Sets and/or Attributes.

When the XSLT is processed the result will be that in Figure 6:

Figure 6: Result of a processed Brick
      <fo:block font-size="12.5pt" font-family="serif" foa:name="customer" foa:group="paragraph">
      customer info
      </fo:block>
    

A complex Brick, such as the one for lists, is composed of a set of simple Bricks that transform the different parts of a complex element. Inside a list, there are items, labels and bodies; therefore the list Brick is composed of four different Bricks: one is responsible for the layout of the entire list, one for the items, one for the labels and one for the bodies. The author can express different styles for each one of these levels, and must also provide the appropriate content information. Figure 7 shows a filled list Brick.

Figure 7: A filled list Brick (composed of 3 sub-Bricks)
[Link to open this graphic in a separate page]

The production of complex Bricks is completely transparent to the author and the order of the elements inside the XSLT project file is irrelevant. During the parsing process, FOA will compose the Bricks by properly loading inside the tree structure all the sub-Bricks composing the complex one. The Bricks will be added as new features of the application and with their flexibility they will provide a huge range of different styling solutions that will cover all those available by FO technology.

A re-usable style component: Attribute Set

As for the transformation process, the author will expect style components to be re-usable. In fact, defining complex styles for some content can be a long process for the author and it can often be achieved only by trial and error. Moreover documents such as company reports, which are created in some well-defined environments, must share the same layout. The author will want to create sets of attributes and a transformation process once, and re-use them both for many documents.

There are similar approaches in literature, in which the presentation rules are expressed in a declarative language. One of these declarative languages was introduced with Grif [13]. These rules define parameters such as font, color, spacing etc... . Presentational rules are gathered in presentation models that can be associated with a generic logical structure (an equivalent of an XML tree) changing the entire document aspect.

These paradigms are very powerful and the Formatting Object does not provide the same structure that CSS, for instance, does in giving a general definition of attributes to be applied to all HTML paragraphs. However this kind of "global" style can be achieved using the XSLT paradigm <attribute-set> and xsl:use-attribute-sets to specify which set must be used for that FO element.

Figure 8 depicts an example of an Attribute Set:

Figure 8: An Attribute Set
[Link to open this graphic in a separate page]

FOA stores in each Attribute Set all the style information that the author has specified. To make it easier to select the correct property settings, FOA subdivides the properties into common and specific subsets, in the same way as in the XSL-FO specification [8]. Like the Brick, the Attribute Set also has a foa:class definition that tells FOA which kind of class can use the set.

Figures 9 and 10 show how the author can deal with Attribute Sets. The first picture shows the Attribute Sets for the "block" class, and the Attribute Set "Normal" is expanded to show all the defined properties. The menu shows author options to manage an Attribute Set. Choosing one of these options, FOA will present the property dialog where it is possible to set all the available properties for that class. The properties are subdivided into common and specific ones, as the FO specification does.

Figure 9: Management of Attribute Sets (using subdivision in classes)
[Link to open this graphic in a separate page]
Figure 10: Properties Dialog
[Link to open this graphic in a separate page]

The XSLT specification also allows the author to define a set that can use another Attribute Set. This paradigm is very important because the FO technology is based on the object-oriented model, in which every formatting object can inherit, specify and override properties expressed in its ancestors. FOA supports this by using the concept of a variant. Starting from an attribute set, the author can define a variant of it in order to add or modify some of its defined values. Figure 9 shows some variants, for instance, ServNameNavy is a variant of Normal that specifies additional properties like color and font weight and overrides the font size. FOA allows the creation of variants only inside a class in order to avoid the possibility of adding incorrect attributes to a Formatting Object.

A consistent preview: Rendered Document XML Description

FOA is not a WYSIWYG application. Therefore, it is important to have a consistent preview to give the author feedback about the effect of the chosen styling on the document. To achieve this, the application must render the entire document using the generated XSLT applied to the XML content. In order for FOA to be an authoring tool that is not dependent upon any specific implementation of a rendering engine, an XML description of a rendered document has been defined as part of the architecture. Using this description, FOA can open a preview window in which the author can see the rendered result.

Figure 11 shows the way in which FOA uses a rendering engine to generate the Rendered Document XML Description while maintaining independence from both the rendering engine and the XSLT processor.

Figure 11: Separation of FOA from the XSLT Processor and the Render Engine
[Link to open this graphic in a separate page]

As well as the rendered description, another XML file describing the logical structure of the rendered document is also returned by the render engine. This second description preserves the logical structure of the document in order to better relate the preview to the original style information.

In general, a single Brick could be used to style many elements inside a document. For example, a paragraph style can be applied to many paragraphs inside the document. Using the information in the Logic Description Tree, the tool can generate a visual link between the rendered areas of the document and the associated style so that the author can check or modify the effect on a particular paragraph.

As another example, a table in a rendered document may have several areas that are created starting from the same Brick. So if the author wants to see the impact of changing the table style, it must be possible to show the amount of content inside the document that will be affected.

A Rendered Document XML Description example is presented in Figure 12 and the corresponding XML Logic Description Tree is presented in Figure 13. These examples were obtained with an experimental version of a rendering engine developed in Hewlett-Packard Laboratories. However, other rendering engines, such as Apache's FOP [14], could be extended to generate a similar output.

Figure 12: Rendered Document XML Description (extract)
[Link to open this graphic in a separate page]
Figure 13: Logic Description Tree of the Rendered Document
[Link to open this graphic in a separate page]

The Rendered Document XML Description is primarily a notation that expresses the areas created during the rendering process including the area position information inside the page (always absolute) and the area dimensions.

The FOA preview can take this information, together with the Logic Description Tree, and present the rendered document, page by page. The author can highlight an entry in the Logic Description Tree and see the associated area in the rendered document. FOA also has all the information necessary to retrieve the Brick that has generated the area and the corresponding style that was applied to it. If needed, at this point, the author can modify the attributes and asks for a new preview to check the effect of the modification.

The class and instance information from the tree are used to highlight the correct amount of information inside the rendered document and to retrieve the applied style. FOA will understand in which class the template was created from the name of the tree tag (in Figure 13 the class TransactionList[list] is related to the tag list-block). The information inserted in the square parenthesis gives FOA the link to the group in which the Brick is positioned; in this way, it will be possible to re-call that Brick directly from the Preview window.

Figure 14 shows the loop-back solution that brings the Author from the Logic Tree representation inside the preview to the dialog box of the selected (highlighted) Brick making simpler to keep track of the formatting results inside the full document.

Figure 14: Loop back solution
[Link to open this graphic in a separate page]

Figure 15 shows the full preview of the "SimpleLetter.xsl" downloadable from the Example section of FOA web site [4].

Figure 15: FOA Preview complete example
[Link to open this graphic in a separate page]

Conclusion

The adoption of a complex but powerful technology such as XSL-FO depends on providing tools that allow authors to create documents without requiring the skills of a programmer. FOA is an experimental authoring tool that provides visual support for creating XSLT style-sheets which transform XML content into XSL-FO documents.

The re-usability provided by the Bricks and Attribute Sets permit authors to create a pool of styling components suitable for more than a single document. The Rendered Document Description and the corresponding Logic Description Tree allow the author to gain maximum value from a rendered document preview.

In this way, FOA provides the kind of assistance in the XML authoring environment that style templates offer in conventional word processing.

FOA is downloadable from the Sourceforge FOA Project web page [4] and contains a full set of examples as well as a tutorial which explains how to use the application.


Acknowledgments

This work has been carried out in collaboration with the Biophysical and Electronic Engineering Department (D.I.B.E.) of the University of Genoa.

In particular, I would like to thank Dr. Anna Marina Scapolla for her support in proposing this as a Masters project and her co-supervision, and to Emiliano Grigis for his implementation of substantial pieces of the tool as part of his thesis.

I would also like to thank my colleague at HP, Roger Gimson, for his comments and help in preparing this document.


Bibliography

[1] J. Andre', R. Furuta and V. Quint, "Structured Documents", Cambridge University Press, 1989.

[10] McGrath, S., "Rendering XML documents using XSL", Dr. Dobbs Journal, Vol. 8 Art. 8 (Jul 1998).

[11] James Clark, XT, http://www.jclark.com/xml/xt.html

[12] Michael Kay, Saxon, http://users.iclway.co.uk/mhkay/saxon

[13] V. Quint and I. Vatton, "Grif: an Interactive System for Structured Document Manipulation", Text Processing and Document Manipulation, Proceedings of the International Conference, J.C. van Vliet, ed., 200-213, Cambridge University Press, 1986.

[14] Apache's FOP, XML Apache Project, http://xml.apache.org/fop/

[2] B. K. Reid, "A Document Specification Language and its Compiler", PhD thesis, Carnegie-Mellon University, October 1980.

[3] L. Lamport, "LaTeX: A Document Preparation System", Addison-Wesley Publishing Company, Reading, Massachusetts, 1986.

[4] FOA web page, http://foa.sourceforge.net

[5] W3C Document Formats Domain, http://www.w3.org/Style/XSL/

[6] XSL web page, World Wide Web Consortium, http://www.w3.org/Style/XSL/ (2001)

[7] XSL Transformations (XSLT) Specifications Version 1.1 (Working Draft), World Wide Web Consortium, http://www.w3.org/TR/xslt11 (12 December 2000).

[8] XSL Specifications (XSL-FO) Version 1.0 (Recommendation), World Wide Web Consortium, http://www.w3.org/TR/2001/REC-xsl-20011015 (15 October 2001).

[9] Walsh, N., "The Extensible Style Language: XSL", WEB Techniques, Vol.4 no. 1 (49-50,52,54-5) (Jan 1999).



FOA: an XSL-FO Authoring Tool

Fabio Giannetti [Hewlett Packard Laboratories]
Fabio_Giannetti@hp.com