Formatting Objects Authoring

SourceForge Logo

Hello World Example (download it)

Author: John Pedersen

This is just about the most simple thing you can do with FOA.

1. The document with your original text.

The point of the exercise is to transform some plain unformatted text into a nice PDF document. Let's say you want to take that classic phrase "Hello World" as an example.

Your literary masterpiece needs to be in the form of an XML file:

Here are the contents of the XML file:

<?xml version='1.0' encoding="UTF-8" ?>
    <paragraph>Hello World</paragraph>

Once you have this file, which contains your data to publish, you're ready to fire up FOA.

2. Setting up the project.

From the FOA Main Menu (on the Formatting Object Authoring tool window), select Project/New...

Use the dialog window to move to the directory where you want to keep your project, and enter a file name such as "example".

This action assigns a file name, but doesn't actually create a file. Go ahead and use the Main Menu to select Project/Save; this will create a file called "example.xsl" in the directory you picked.

3. Setting up one or more Attributes.

The next essential element: whatever you plan to print, has to have one or more attributes (such as font, size...)

So we need to set up an attribute file. Use the Attribute Set Manager, and click the icon for a "New" set of attributes.

Use the dialog window to move to your project directory and enter a file name such as "example". Don't bother adding an extension to the file name.

As with the project file name, you have now assigned a file name for your attributes, but you haven't written the file. Go ahead and click on Save icon on the toolbar at the top of the Attribute Set Manager window to create the file. If you look in the projects directory, you will see that the name you specified has been modified to "exampleAtts.xsl".

(There is a very good reason for keeping attributes in a separate file. You may develop preferences for certain formatting, and this allows you to quickly apply these attributes which you or your company have adapted as "standard", to various different documents.)

Now the Attribute Set Manager shows the available classes of attributes, in the left panel. Click on block. The right panel shows that no attributes have been set for this class.

Click the right mouse button in the right window panel. A context menu with one item appears: "New Attribute Set..." Select this, and wait for the dialog window for entering your attributes.

For our example, we will go with ALL the default values, so simply click "Update" on the bottom of the window, and give this Attribute Set a name, such as Standard Paragraph.

At any time you want to see what attributes you have created, click on the left panel attribute class (such as "block"), and double-click on the "Attribute Sets" in the right panel.

Save your changes to the attributes file now. Click the "save icon" at the top of the Attribute Set Manager.

4. Bring your source document into the mix.

Use the XML Content Manager to open your Hello World source document. Click the "Open" icon in the tool bar, and use the dialog to select your source file.

You will see the tags of your simple document in the XML Content Manager window.

5. Set up a page to print on.

Select the Pages icon in the Page Manager window, and right mouse click in the window. A context menu with only a single choice appears; click on "New Page...".

Once again, on the Page Properties dialog that appears, accept the all the default values, for now, and click "Update".

When it asks for the page name, call it "FirstPage".

Now, even though we are only going to print on one page, we need to define a "page sequence". Use the Page Sequence Manager. Select the Page Sequences icon, and right mouse click in the window. Click the "New Page Sequence..." context menu.

On the dialog, select "Single", and click Continue.

On the Select Pages dialog, select "FirstPage" from the dropdown list, and click "Add".

Give the sequence the name "ExampleSequence". This sequence is automatically added to the Content Sequence Manager window.

Now that we have a page to print on, let's apply the formatting to the document.

6. Setting up bricks.

In this step, we make the connections (only one, in this case) from the attributes to certain parts of the document.

In the left pane of the Brick Manager, select "paragraph". We see that no bricks have been defined yet. Select the brick icon and right mouse click in the window, then click on "New Brick..."

  1. Name the brick "HelloParagraph"
  2. Click "Change Match", then go to the XML Content Manager, note the check mark showing "Tag Selection Enabled", and select the tag. If you don't see it, expand the "mydocument" node. Next, right click in the window to get the "Match Content" menu, and click it.

Click "Continue" on the Tag Parameters dialog. As you can see, you have now made a connection from the brick to your paragraph.

Now you have to "draw the connection" to the Attributes.

Still working with the Paragraph Brick dialog, choose the "Brick Content" tab at the top. Activate the Style dropdown list and select the single item--the Standard Paragraph attribute.

You have now made a connection from your attribute, all the way over to your document.

7. Placing the print on the page.

One last thing to do. Use the Content Sequence Manager.

Select Example Sequence in the left pane; double click the Example Sequence in the RIGHT pane, which shows an icon representing the "body" area of the page.

Select the "body" icon, and right mouse click. Click on the "New Last Content Sequence Reference".

On the resulting dialog, click Change Content Reference. Once again, you will see that the XML Content Manager becomes Tag Selection Enabled. Select the tag, and right mouse click, and then click "Select Content". Click Continue on the next dialog, and you're done.

8. Save your Attributes file, and save your Project file.

The Attributes file looks like this:

<xsl:stylesheet xmlns:xsl="" version="1.0" xmlns:fo="" xmlns:fox="" xmlns:foa="http://fabio">
  <xsl:attribute-set name="StandardParagraph" foa:class="block">

And the Project file looks like this:

<xsl:stylesheet xmlns:xsl="" version="1.0" xmlns:fo="" xmlns:fox="" xmlns:foa="http://fabio">
  <xsl:import href="exampleAtts.xsl"></xsl:import>
  <xsl:output method="xml" encoding="UTF-8"></xsl:output>
  <xsl:variable name="dots">l</xsl:variable>
  <xsl:variable name="circles">m</xsl:variable>
  <xsl:variable name="squares">n</xsl:variable>
  <xsl:template match="/">
    <fo:root xmlns:fo="">
        <fo:simple-page-master master-name="FirstPage">
          <fo:region-body ></fo:region-body >
        <fo:page-sequence-master master-name="ExampleSequence">
          <fo:single-page-master-reference master-name="FirstPage"/>
      <fo:page-sequence  master-name="ExampleSequence">
        <fo:flow  flow-name="xsl-region-body">
          <xsl:apply-templates select="document('document.xml')/mydocument"/>
        </fo:flow >
      </fo:page-sequence >
  <xsl:template match="mydocument/paragraph" foa:name="HelloParagraph" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="HelloParagraph" foa:group="paragraph" xsl:use-attribute-sets="StandardParagraph">