XML Extensions - Bar Chart

A bar chart (SimpleGraph.cbl) is the first example. It is purposely simple, with the exception of the method used to color the bars. In many ways this example violates the principle of separation of data from the presentation layer. However, instead of specifying a bar color, an ‘urgency’ is specified for each data value. The XSLT stylesheet, which transforms the data into the SVG image of a bar chart, translates ‘urgency’ into a color.

The XSLT stylesheet uses several standard techniques to ‘draw’ the bar chart, including recursion for layout of various elements. The urgency is translated to a color in the template that matches graph-bar, in the computation of the bar_color variable. A second XML document, named urgency.xml, is used to look up the urgency number and place the corresponding color name as the value of $bar_color.