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.
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  as well as mature tools such as Scribe  and LaTeX .
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  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  as the first available XSL Authoring tool.
XSL [Extensible Stylesheet Language]  is a W3C standard that consists of two parts, a transformation language called XSLT  and a presentation markup language usually called XSL-FO or simply FO . 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 . 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 .
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   during the XSL stylesheet transformation. Figure 1 shows the two-step process to obtain a final rendered document in a deliverable page description language.
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.
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 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.
Each Manager works on different aspects of the authoring process; there are six different Managers as follows:
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 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.
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.
<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:
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:
<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.
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.
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 . 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:
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 . 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.
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.
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.
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 , could be extended to generate a similar output.
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.
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  and contains a full set of examples as well as a tutorial which explains how to use the application.
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.
 J. Andre', R. Furuta and V. Quint, "Structured Documents", Cambridge University Press, 1989.
 McGrath, S., "Rendering XML documents using XSL", Dr. Dobbs Journal, Vol. 8 Art. 8 (Jul 1998).
 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.
 B. K. Reid, "A Document Specification Language and its Compiler", PhD thesis, Carnegie-Mellon University, October 1980.
 L. Lamport, "LaTeX: A Document Preparation System", Addison-Wesley Publishing Company, Reading, Massachusetts, 1986.
 Walsh, N., "The Extensible Style Language: XSL", WEB Techniques, Vol.4 no. 1 (49-50,52,54-5) (Jan 1999).