You are not logged in. Login  or register.

Learn XSL-FO

Templated documents


We've all seen many documents in our life. Government forms, job contracts, and even plane tickets — they all are documents.

Documents are not constant. They change very often. Say, you have your name mentioned in a document several times, and you need to prepare a similar document for someone else. Search–and–replace is time consuming and error–prone.
Another example is when you need to change formatting — e.g., make all your headers bold.

Let's take a simple document:

Dear Mary and John,

Our joy will be more complete if you can

share in the marriage of our daughter

Susette Ann


Jordan Jake Alletts

on Saturday, June twenty-first

two thousand eighteen

at three o'clock in the afternoon

12345 Main St. Little Falls, Virginia

Mr. and Mrs. Frank Hall

Suppose you need to send this invitation to a group of people that are listed in your address book. Since you are not a printing agency, the names of bride and groom, addresses, and dates are constant. So the only part that actually changes is the name of your guest. Your goal is to create a document that would ...

Templated document

The solution is called templated documents. Thus, you document consists of two parts:

  • Data that contains only essential information, e.g. name is John, age is 25, etc.;
  • Template that contains everything that is common for all documents of this kind. Template data includes static text ("Our joy..." in a sample above) and formatting patterns such as font and color information.

In order to make a document for someone else, you just provide with another set of Data. To modify the style, you only modify the template, and all new documents will have this change at once.

How do I arrange my data?

The most common industry standard is XML. You may have heard of it, but even if not, your computer is already using it extensively for various service features.

A typical XML document looks like this:

<?xml version="1.0"?>
        <name>Mary and John</name>
        <street>25, Main st.</street>
        <note>My best friends</note>

The document may have (and usually has!) repeating items, like this:

<?xml version="1.0"?>
        <name>Mary and John</name>
        <street>25, Main st.</street>
        <note>My best friends</note>
        <street>1, Another ave.</street>
        <city>San Francisco</city>

Further reading:

What about the template?

As discussed above, a template contains all information that is common to the document type. In fact, a template contains only information on how to represent the data, but not the data itself.

Usually, a template is tightly bound to the structure of data that is discussed above. This means that the template prepared for wedding invitation would be useless for printing a bank statement.

Therefore, you should first prepare your data and then build up your template that will apply formatting.

Now, let's look how to specify the formatting for your data. The formatting language is called XSL-FO. It provides with rich formatting features and it is suitable for wide range of documents.

Let's look on a snippet that inserts a name of invited person in the sample above (note this is not a complete template):

<fo:block text-align="center">
    <fo:inline font-size="22pt"
        white-space-collapse="false">Dear </fo:inline>
        font-family="Arial" font-size="24pt"
        <rxsl:value-of select="name" />
    <fo:inline font-size="22pt">,</fo:inline>
<fo:block text-align="center">
    <fo:inline font-family="Calibri" font-size="24pt">
        Our joy will be more complete if you can

Please note that the template does not contain "Mary and John", it only refers an element called "name".

TODO: basic features of FO

Processing XSL-FO

So, first of all, your data (XML) is processed with the template (XSL). The result document contains both data and formatting, according to XSL-FO conventions. It is also an XML, and now it is ready to be actually rendered to required media, which may be PDF, PostScript, or various other formats.

Formatting with XSL-FO

There are many tools that process XSL-FO to printable formats:

Apache™ FOP is a free formatting processor based on Java. Once installed, it provides with formatting capabilities to a set of various output formats.

RenderX XEP is a powerful formatting engine takes input in XML, applies an XSL transformation to build XSL Formatting Objects representation, and then formats the Formatting Objects into all formats supported. XEP supports multiple raster and vector graphic formats.

Why should I use XEP Online?

XEP Online is designed for those who require quality documents but do not want installing any software on their computer.

Installing a sophisticated tool might be tricky for a non-technical person. What if you just need your document formatted, without fiddling with all those settings? XEP Online is the answer. Just upload your data and template to the system and receive a formatted PDF document. As simple as this.

When you get familiar with the technology and relevant tools and decide upgrading to a full version, your documents wll require no change for a full XEP.

Ready to try?

If you are not yet familiar with technologies listed above, we suggest you start with our samples directory. All samples are ready for processing. You may download the full sample (ZIP) to your computer, modify source data, a template, or both, and upload back to XEP Online to get formatted PDF.

What if I need integrating this service to my application?

XEP Online supports integration into your application, and it is also free. Your application will invoke the Web Service, providing with source XML and XSL, and receive the resulting PDF.  You have two options:

  1. XEP API. This Web Service is using an HTTP REST interface and seems to be most simple to integrate. Follow to view details.
  2. Fairy is a different Web Service using SOAP technology which is widely popular across Windows and Java communities.

Both services have similar functionality, so your choice is rather a matter of taste and professional preferences.

What fonts are available?

XEP Online has been configured to support default fonts available in desktop XEP for Windows. Those fonts are:

  • Helvetica (also serves as default fallback font if an unknown font is used in your socuments);
  • Base Adobe fonts: Courier, Times, Symbol, ZapfDingbats;
  • Windows fonts: Arial, Times New Roman, Courier New, Tahoma, Verdana, Palatino;

What languages are supported?

XEP Online supports any languages as long as the fonts are available. Also, automatic hyphenation is turned off, so thare is no need of specific support of language-aware dictionaries.

I'm concerned about sending my data to a Web service.

XEP Online is a free tool. We don't limit using it for various purposes, but in general, any data sent across the Internet is vulnerable to theft. It may be intercepted and misused.

Here are the key issues:

  • XEP Online stores data while your Web session exists. As soon as the session ends due to inactivity (30 minutes), the data is deleted; While the data persists, an attacker may forge your session cookie and get access to your data;
  • If the measures above are not sufficient for your needs, you may consider an installable tool that runs on your machine, without getting connected to any services over the Net.


Copyright © 2012 RenderX. Portions copyright © by original authors, rights reserved, used by permission.       Design by