Using XSLT with Sevilla

One of the reports Sevilla can produce is the XML dump. Hardly understood by some and one of the most appreciated features by others, it’s time to explain one of the most interesting possibilities: To create web pages from the dump using style sheet processing.

Style sheet processing is a technique that processes an XML file, based on some cookbook, to some kind of output. The cookbook is an XML stylesheet and is also an XML file. It is written in a stylesheet processing language: XSL. The style sheet processing is called XSLT. XML stylesheet language transformation.

It is important to know how to build these stylesheets if you want to use the feature. I will not start a crash course XSLT here because there are various resources on the web, like Better even is buying a good XML book. Some global understanding of html and xml in general is strongly recommended before building style sheets.

Now lets go into some detail what style sheet processing means. Look at the schema:

Style sheet processing is done by a style sheet processor. It picks up a style sheet, and an input file. Then it processes the input file, based on the rules in the stylesheet to an output file. The output file can for instance be an html document.

Now you need three things to generate the output, don’t you? You need a style sheet processor, a style sheet and an XML document to process.

If we want to create html pages from the XML output from Sevilla we first need an XML output. This is easy: generate an XML dump from Sevilla, using the option in the report menu. This Sevilla output serves as the XML document in the image above, and hence as the input document for the style sheet processor.

Next you need a style sheet processor. There are various but I found Xalan to be a good one. It can be downloaded from, but I added an easy to install version here. Xalan needs an other program, called Xerces. This can be download from too, but an easy to install version is here. Get Xalan and Xerces and install them. Another style sheet processor can do the job, but the rest of this page assumes Xalan. Install Xalan and Xerces.

Last we need the stylesheet. You can use the stylesheets I use for my chess club Ca├»ssa. You can get them here. Download them and unpack the file into some directory. But you can also try Tom Visser’s stylesheets. Tom, who is the driving force behind the XML dump, created completely different ones for his club Schaakclub Roden and kindly permitted me to add them here. The two together show well the endless possibilities this technique offers.

There a two so called bat files which need modification for your specific situation. To edit them, open them with notepad or wordpad or a similar tool. Use of Word is not recommended. First edit xalan.bat. It looks something like this:

@echo off
rem set the location of Xalan en Xerces
set XALAN=C:\xml\xalan
set XERCES=C:\xml\xerces

rem call Xalan
set PATH=%PATH%;%XALAN%\bin;%XALAN%\lib;%XERCES%\lib;%XERCES%\bin
%XALAN%\bin\xalan %1 %2 %3 %4 %5 %6 %7 %8 %9

rem clean-up the environment variables
set XALAN=

Make sure the locations of Xalan and Xerces are set correctly, to the paths where you installed them. Change it according to your situation and save the file.

The second bat files is build.bat, and looks like this:

@echo off
rem setting which paring system you use
rem set SYST=SWISS

rem setting where the style sheets are to be found
set XSL=.
rem settings that control the location of the .sev file and the .xml output file
set SRC=.\Competition.sev
set DUMP=.\output.xml

rem the main part: running xalan
call xalan.bat -o “games.html” “%SRC%” “%XSL%\games.xsl”
rem call xalan.bat -o “histbsc.html” “%SRC%” “%XSL%\history.xsl”
if not “%SYST%” == “SWISS” call xalan.bat -o “ranking.html” “%DUMP%” “%XSL%\ranking.xsl”
if “%SYST%” == “SWISS” call xalan.bat -o “ranking.html” “%DUMP%” “%XSL%\rankingsws.xsl”
call xalan.bat -o “rating.html” “%DUMP%” “%XSL%\rating.xsl”
call xalan.bat -o “tpr.html” “%DUMP%” “%XSL%\tpr.xsl”
call xalan.bat -o “sevperc.html” “%DUMP%” “%XSL%\sevperc.xsl”
call xalan.bat -o “rtginc.html” “%DUMP%” “%XSL%\rtginc.xsl”
if not “%SYST%” == “SWISS” call xalan.bat -o “history.html” “%DUMP%” “%XSL%\exthist.xsl”
if “%SYST%” == “SWISS” call xalan.bat -o “history.html” “%DUMP%” “%XSL%\exthistsws.xsl”

rem clean environment variables
set DUMP=
set SRC=
set XSL=
set SYST=

The line starting with set SYST should reflect the pairing system used. If you use a Swiss competition remove the rem from the line with Swiss, and add it to the line with Keizer:

Then the lines with set SRC and set DUMP should tell the location of your Sevilla file, and of your Sevilla XML output document. Change the lines as needed for your situation. Then save the file.

Now we have prepared everything to create the documents. This is very easy: just run the file build.bat. You can doubleclick it from Explorer, or open a command window and type build. After a short while the program shoud end and the html documents should be generated in the same directory. If you try to view them by double clicking some nice page should appear.

You can easily modify the xsl documents provided if you want to. To make bigger changes XSLT knowledge is needed. If you are somewhat experienced with XSLT the big challenge is to create your own style sheets to make much nicer pages than I did – you can of course still peek into my or Tom’s examples because you still have to deal with the same Sevilla output.

Good luck.