Page generation using XML and XSLT

These pages may well appear to be yet another set of amateur pages, earnest but dull, or as a friend said:
Awesome! But I gotta tell you, awful dull.
Momentarily I suddenly grew rather fond of her, and then just as suddenly not.

Nonetheless, there is a little bit more to them. Initially I did them with frames, so that I wouldn't have to repeat the navigation information on each. Then I found that the search engines were referencing the individual frame pages, and so losing the navigation information. Someone would come into the bibliography and not be aware that there was anything else.

To rectify this I decided to do away with the frames, but still being lazy, how to include standard parts into each without needless and error-prone repetition? After a few dead-ends, I settled on using XSLT. I found a xslt processor which I could persuade to work. This is from

As I generated the xml files from my original html files, I developed an xsl file which is used to transform the xml files to html. The xsl file automatically includes the navigation bar, generates the title and main heading and standardises the appearance of the pages. Should I decide to take my friends advice and add some colour to the pages then all it requires is a simple tweak to the xsl file.

An example xml file: biblio.xml. An extract from that file:-

<bookauthor>Fraser, Antonia </bookauthor>
<booktitle> Warrior Queens (originally entitled Boadicea's Chariot) </booktitle>
<bookpublisher>Weidenfeld & Nicolson, London 1988 ISBN: 0 297 79486 8</bookpublisher>
A study of women leaders, their lives and
how they are perceived. Apart from Lakshmibai (The Valiant Rani) it includes
Boadicea, Margaret Thatcher and Indira Gandhi among others.

Note that the bookpublisher data could be broken down further, as could the author's name.

Using XSLT I can pick out any, or none, of these fields and embed them in HTML to produce any layout and style I wish.

Using xslt also means that alternate versions of a page can be generated, for example the bibliography could be generated as a simple list of titles and authors say, sorted on title and with no other information present.

The Site Map is generated from a list of pages, and the XSLT then fetches the information it needs from the XML pages itself.

The site map XML looks like this:-



<pageref base="timeline" >Timeline</pageref>
<pageref base="early" >Early life</pageref>
<pageref base="retire" >Annexation</pageref>
Adding a new page to it is easy.

Then the navigation bar is generated from the site map XML using its own XSLT file, nav.xsl

[Since writing this, I decided to add the next and previous links to each page. Again this was a simple matter of using XSLT to reference the sitemap and it all happened automatically and consistently. Very neat.]

Finally, a few tweaks of the lakshmibai.xsl file produces a completedoc.xsl with which I can generate a single document containing all the web pages on the site. Links are rendered as plain text, not as the usual link, images are removed, and with one or two other formatting tweaks we have a single printable document.

Further, because all the HTML files are derived from a single set of XML source files, there is no problem with keeping them up to date. A change in one will automatically follow through to any file derived from it.

There are a million and one other techniques for doing this sort of thing, but XSLT and XML have theadvantage of being geared for the net, and of being accepted by some of the major names in the industry, as well as me.

And on the downside, I lose the pretty WYSIWYG page editors, but I'm quite happy with a text editor. One advantage of being an old fart.