Carte Fact Sheet

Carlos Amengual, amengual at informatica.info

Revision date: Jan. 2, 2007

Latest version at the Carte web site.

Purpose of this Document

This document briefly describes some basic facts about the Carte report engine, its architecture and intended use. Topics such as the use of XSL and CSS standards to format documents are also discussed. You are encouraged to read this paper if you are looking for a Java-based report engine, or are interested in the use of standards to print reports.

Main Features

Carte is a partial rewrite of an old Java report engine that the author started several years ago. The legacy engine had a non-standard format to specify the document rendering, something shared with most report engines. Later, the design was revised to allow the use of arbitrary XML formats to specify the formatting of the report document, and the result is Carte.

Carte has the following features:

Standards-based Document Formatting

As mentioned, Carte chose the path of using document formatting standards, as opposed to the usual proprietary formats that other report engines use. Then, we reach a point where we find two possible standard solutions: CSS and XSL.

While there are some discussions comparing XSL and CSS around the Net, most fail to realise that XSL is a family of recommendations, and many people seem to think that XSL is only XSLT. It makes no sense to compare CSS and XSLT, as one specifies formatting, and the other does XML transformation. However, as XSLT is frequently used to transform an XML document into XHTML, it is sometimes taken as a way to "render" XML.

CSS must be compared to XSL:FO, the Formatting Objects part of XSL. An XSL:FO sheet can take an XML document as input, and produce the desired output, for example PDF. For example, Apache FOP is an open source XSL:FO-based print formatter. XSL:FO, however, has problems:

  1. It is enough complicated to require a tool to write the style sheet. One could say that CSS is closer to humans than to the machines, while the opposite happens with XSL:FO.
  2. In practice, you have to write somewhat different XSL sheets for different output formats. An XSL:FO sheet for a PDF output can be extremely different from an XSL:FO to render the same content into another format.
  3. With both CSS and XSL:FO, the final rendering of the document depends strongly on the software used for it. The difference being that with XSL:FO it is easier to come up with templates that will not work correctly (or not work at all) with other software than the one used to write the sheet. In some cases, to print your document you are bound to the tool that also produced the XSL.
  4. XSL:FO implementations have a large memory footprint, and each document rendering operation requires many expensive XPath operations.

The first problem is important as there are no open source XSL:FO GUI builders, and the commercial ones are very expensive and, what is still worse, not very useful. The second problem, combined with the first can make things really difficult.

One example that can be also of help when comparing CSS and XSL:FO is to examine the CSS and XSL sheets used to format an XHTML document. If you use Mozilla Firefox, you can find an html.cs file in the res subdirectory of the main Firefox folder (generally Program Files\Mozilla Firefox). Other browsers (MS Internet Explorer not included) also have their own CSS file. It is harder to find the equivalent XSL:FO sheet, but there is one at the Antenna House web site.

CSS is used extensively by web page designers, and is easy to understand. So it was the styling language chosen for Carte.

Transforming an XML Document into a Report

Any XML format can potentially be used as input for Carte, generally XHTML, but in addition to the formatting you need a way to define how to merge the data with the format. This is done with the use of XML namespaces, and the Carte elements and attributes are responsible for that. All the source XML document must be inside a report element with a namespace definition, for example <xte:report xte:version="0.1" xmlns:xte="http://www.informatica.info/projects/carte/xte">, and then its contents annotated with the Carte elements.

For example, to data-enable an HTML table you just have to use the Carte namespace prefix, in our example "xte", and the tag would look like <xte:table xte:dataspec="mydatasource">. Analogously, a report chart comes from changing the img element into something like <xte:img xte:type="barchart" xte:dataspec="mydatasource">.

Getting Started

If you are in a hurry, you can obtain a very simple XHTML template to print a table from an SQL query using the ReportUtil convenience class. If you want a report optimized for text (just for XHTML pages) you have to run:

java info.informatica.report.ReportUtil --driver=<jdbc-driver> --datasrc=<data-source>
  --name=<name> "<SQL query>"

where "name" is the name that you want to give to your SQL query in the report. And, if you want a report that can generate both text and PDF, run:

java info.informatica.report.ReportUtil --driver=<jdbc-driver> --datasrc=<data-source>
  --name=<name> --blocktype=table "<SQL query>"

In any case, you can then store your template in a file somewhere, and run this to print the report:

java info.informatica.report.Report --driver=<jdbc-driver> --datasrc=<data-source>
  --name=<name> --templatepath=<path to template> "<SQL query>"

The result is poor, but gives you a starting point. You may want to give your own format to the generated XHTML template to get a better view.

Market Niche

Carte still lacks several functionalities present in other report engines, like a wide variety of charts. However, works well enough to be in production at several sites. The main points for Carte adoption are:

BSD License

Carte's BSD license makes it legally safe to ship with software having licenses different than GPL or LGPL. All the open source report engines the author knows about, are under an LGPL-style license, or even the GPL. The LGPL is not safe to use with software having other licenses than LGPL/GPL.

Do not invest in proprietary formats

Most, if not all other report engines, define their own proprietary document rendering format. Instead, Carte uses the well-understood CSS definition language, which is simple, powerful and standard.

Same style specification as web pages

CSS is in widespread use by web page designers, which means that you can enforce in your reports the same corporate style already defined for your web pages. No need to learn new style specifications, and you can reuse your investment in web site style definition.

Extensible architecture

Carte is designed in a way that it is easy to customize it by adding your own charts, output formats and even origin formats.

Roadmap

Future work is going to concentrate in the following areas, several of which are partly implemented:

If you want to contribute to the development of Carte, please contact the author.