Andre's Blog
Perfection is when there is nothing left to take away
XML Reports in Stone Steps Webalizer

Generating reports in XML has been on my list of things to do for a while and I finally got around to work on it. One might ask, what is so significant about XML and why would an average webmaster be interested in them? Good question.

XML and related technologies provide a neat and powerful way to separate what reports contain, such as hit and visit counts or a list of hosts and URLs, from how reports are presented. As simple as this sounds (and, may be, cryptic to some readers), this separation is the basis for better-looking and much more customizable reports.

The great thing about Webalizer reports is that they are presented in a simple and easy to use way - all main reports lined up on a single monthly page, which makes very simple to browse through the report by just scrolling your mouse wheel. However, it was not easy to customize the reports because the HTML, down to the color of every element, was hard-coded into the C++ source in the original Webalizer. Here's a sample of the HTML produced by v2.01-10:

Monthly Statistics for May 1999</TH></TR>
<TR><TD><FONT SIZE="-1">Hits per Hour</FONT></TD>
<TD ALIGN=right WIDTH=65><FONT SIZE="-1"><B>265</B></FONT></TD>

Note that text color, background and font sizes are defined right in the HTML, which means that once reports are generated, one would have to edit all of them in order to change the color of a single cell header or page background.

Stone Steps Webalizer improved this by introducing Cascading Style Sheets (CSS), so report HTML looked like this:

<table class="report_table monthly_totals_table">
<colgroup><col><col span="2" class="totals_data_col"></colgroup>
<thead><tr class="table_title_tr"><th colspan="3">
Monthly Statistics for May 2008</th></tr>
<tbody class="totals_data_tbody">
<tr><th>Hits per Hour</th>

CSS allowed webmasters to control the color scheme of the reports and, to some extent, report layout, so that one would modify a single shared CSS file in order to change page background color, font type, etc.

However, CSS just improved report management, but not eliminated the main problem - a big part of the report presentation, such as report layout tables, the color of the graphs, etc, was still generated by Stone steps Webalizer and one would need to generate reports again in order to change something like the color of the graph or, worse, have to change the C++ code in order to modify report layout.

This is where XML reports come in. If Stone Steps Webalizer generated just data, which could be formatted using other XML technologies, such as XSL, webmasters would have full control over the report layout and color scheme.

Let's consider an example. Imagine a simple report with just a couple of numbers. Such report could be output in XML as follows:

<?xml-stylesheet type="text/xml" href="webalizer.xsl"?>
  <data name="hits">265</data>
  <data name="pages">112</data>

Note that the report no longer contains any presentation information, be that layout tables or font and color data. Other technologies capable of working with XML can now be used to present this data in a variety of formats. For example, an XSL style sheet can be attached to this report to generate an HTML report similar to the one Stone Steps Webalizer produces now.

Those familiar with XSL might ask at this point about the graphs, since XSL cannot be used to produce any form of graphics. However, XSL can convert data sets to other formats that that can be used by various existing graphing solutions. For example, a Flash chart can be configured in an XSL template and presented in the final report HTML. Similarly, SVG can be used to generate vector graphs.

XSL style sheets, being just text files, can be modified using a simple text editor, such as Notepad or vim, which makes it very easy to customize the reports. For example, in order to disable the country report, one wouldn't have to change webalizer.conf and generate a new set of reports, but instead could just remove the country template from the XSL stylesheet and refresh the report in the browser. XML makes it that easy.

Update 2019-12-14

XML reports never picked up popularity and were removed in SSW v4.2.