Using XSL formatting for XML Traffic Reports

XSL stands for Extensible Stylesheet Language. It is kind of the XML equivalent of Cascading Stylesheets (CSS). Since XML data by itself does not contain any information on how to render its contents, a style sheet needs to be attached to it in order to convert it into HTML, PDF, RTF, GIF or any other display format.

Here is an example of XML document produced by TMeter:

<?xml version="1.0"?>
<TrafficReport>
        <Filter Id="1">
                <Name&gtICMP</Name>
                <Sent&gt7224</Sent>
                <Recv&gt7224</Recv>
        </Filter>
        <Filter Id="2">
                <Name&gtTCP</Name>
                <Sent&gt3566</Sent>
                <Recv&gt8967</Recv>
        </Filter>
        <LastModified&gtNovember, 26 2002 11:19:14</LastModified>
</TrafficReport>

If you open this document using Microsoft Internet Explorer, it will look like:

This view is not human-friendly. However, let's create XSL formatting (in a separated file traffic.xsl) for the XML document. The content of traffic.xsl is here.

Next, add a reference to the traffic.xsl in a prolog of the XML document:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="traffic.xsl"?>
<TrafficReport>

...and we will get a human-friendly view of the XML document using Microsoft Internet Explorer:

To format the Monthly XML Traffic Reports, use XSL formatting included in the TMeter package.