December 17, 2004

List of XSL-FO processors

XSL-FO is a W3C recommendation for describing layout information. In other words, by attaching a XSL-FO stylesheet to an XML file (content file), we specify how the content should be laid out on an output medium complete with headers/footers, table of contents, indexes etc. With XSL-FO, we can also flow text around images, add footnotes etc. Of course, none of the browsers currently supports this standard. We cannot use XSL-FO for web pages yet. However, we have XSL-FO tools which convert a given XML file to PDF, PS etc.

Here is a list of currently available XSL-FO processors and tools. Please check the respective websites for updated information and pricing.

Apache - FOP (I tested this tool)
  • An open-source free tool.
  • Written in Java.
  • Java interface.
  • PDF, PS, RTF outputs etc.
  • Very good support for XSL-FO specifications.
  • Extensive SVG support. (Yes, you can embed on-the-fly images in PDF using SVG. Helpful for creating dynamic charts and graphs).
  • No major updates to the project since 2003. However, actively maintained for bug fixes.
Antenna House – XSL Formatter V3.2 (I tested this tool)
  • Commerical tool. $5000 per CPU. $3000/$900 developer license.
  • Extensive support for XSL-FO specifications.
  • PDF output.
  • .NET / JAVA interfaces.
  • Very good SVG support.
RenderX – XEP Engine (I tested this tool)
  • Commerical tool. $4000 per CPU.
  • Very good support for XSL-FO specifications.
  • PDF, PS outputs.
  • Java interface. (Connectivity kit for other platforms)
  • Extensive SVG support
Inventive Designers – Scriptura XBOS 3.1
  • Commerical tool. Expensive.
  • PDF, PS, HTML, RTF outputs etc.
  • Requires a Java application server.
  • Java/C++ interfaces.
  • GUI layout designer. (No need to hand code XSL-FO stylesheets)
  • Lots of features
Unicorn Enterprises SA - Unicorn Formatting Objects
  • Commerical tool.
  • PDF, PS, HTML outputs.
  • Very little information on their website.
Visual Programming Limited - Ibex XSL-FO Formatter 3.0
  • Commerical tool. An inexpensive tool.
  • .NET / JAVA interfaces.
  • PDF output.
  • SVG support.
Adobe - Adobe Document Server
  • Commerical tool.
  • C++ interface.
  • PDF output.
  • SVG support.
Ecrion - XF Rendering Server
  • Commerical tool. $805 - $995 per cpu.
  • .NET / COM+ / SOAP interfaces.
  • PDF, HTML, PS outputs.
  • SVG support.
  • GUI designer.
  • Built-in charting feature.
Lunacil - Xinc XSL-FO formatter
  • Commerical tool. $495 per cpu.
  • JAVA/COM interfaces.
  • PDF output.
Altova - Stylevision 2005
  • Commerical tool. Starts at $599 per cpu.
  • No interface listed on their website.
  • PDF/HTML/RTF outputs.
  • GUI designer.
ALTSOFT - Xml2PDF.NET
  • Commerical tool. $49 - $1599(depending on the editions).
  • .NET interface.
  • PDF output.
  • SVG support.
  • GUI tool for formatting.

In the mulberrytech mailing list, I was told that http://www.xmlsoftware.com/xslfo.html has a better listing of xsl-fo tools.

UPDATED: Jan 10, 2005.

</script> cannot be scripted

In ASP.NET, I cannot write the string - "</script>" to the page. The JIT compiler will throw an error. As explained by Microsoft here, this is actually by "design". To work around this issue, I had to split the text into two strings. "</" + "script>". I think any other combination of string concatenation will work too.

December 09, 2004

Finding week number of the year

Recently, I had a requirement to generate a dynamic graph based on weekly data. For this, I decided to use the "group by" clause to group the data by weeks. Very quickly, I realized I was dealing with a nasty problem. The same set of data, but from different databases, will return different results. Determining a consistent week of the year among the different databases was not easy. Why? Because, each database generates the week number of a year differently.

For example, assume 10 units were sold on 12/30/2003 and 20 units on 1/1/2004. After using group by, the result would be 10 units for week number 53 and 20 units for week number 1 in SQLserver. However, in Oracle it would be 10 units for week number 52 (not 53) and 20 units for week number 1. This difference in week number will appear throughout the year and not just at the beginning or end of the year.

In the following tables, I am listing some sample dates and the week number of each date.

Using datepart(param, column) in SQLServer, I get the following results. Notice the effect of the SET DATEFIRST statement. 7 is the default value for SQLServer.

datefirst =1datefirst =1datefirst = 7datefirst = 7
12/27/20035212/27/200352
12/28/20035212/28/200353
12/29/20035312/29/200353
12/30/20035312/30/200353
12/31/20035312/31/200353
1/1/200411/1/20041
1/2/200411/2/20041
1/3/200411/3/20041
1/4/200411/4/20042
1/5/200421/5/20042
1/6/200421/6/20042
1/7/200421/7/20042
1/8/200421/8/20042
1/9/200421/9/20042

Using to_char(column, param) in Oracle, I get the following results for the same dates.

to_char(ww)to_char(ww)to_char(iw)to_char(iw)
12/27/20035212/27/200352
12/28/20035212/28/200352
12/29/20035212/29/20031
12/30/20035212/30/20031
12/31/20035312/31/20031
1/1/200411/1/20041
1/2/200411/2/20041
1/3/200411/3/20041
1/4/200411/4/20041
1/5/200411/5/20042
1/6/200411/6/20042
1/7/200411/7/20042
1/8/200421/8/20042
1/9/200421/9/20042

As you can see from the above data, for a given date, the week number will vary in each database. How does it matter to me? In my case, the data set could potentially be millions of rows. I am using a single query to get the grouped data. However, in the graph, I would like to display all weeks in the x-axis even if it has null data for a particular week. That is, if week 20 has no data, I would like the y-axis value to be 0. Therefore, I programmatically generated all the week numbers given a start and end date. I did this using boost datetime library. Boost uses ISO 8601 standard for generating the week number. To match these generated week numbers, I had to find a way to get ISO standard week numbers in each database. Oracle already had a way to do that. SQLServer did not have a ready made solution. But, I found a ISOWeek function from MSDN, which did what I wanted.

To get a consistent week number, I used the following.
SQLServer:
Set Datefirst 1
ISOWeek(date column)

Oracle:
to_char(date column, "IW")

Boost:
week_iterator
week_number()

Using the above methods, I could generate the same week number no matter which database is used.

DateWeek number
12/27/200352
12/28/200352
12/29/20031
12/30/20031
12/31/20031
1/1/20041
1/2/20041
1/3/20041
1/4/20041
1/5/20042
1/6/20042
1/7/20042
1/8/20042
1/9/20042

Note: In most cases, this might not be a problem. Because, the system would involve just one database or the users may not want ISO standard week number.