Anyone who has ever created or maintained a Web site knows the headaches created by inserting footnotes on a Web page. Here's an elegant solution using DocBook elements to identify footnotes in the XML file along with some efficient XSL transformations to position the footnotes properly on the Web page.

Example of footnotes rendered on a Web page

The Problem with Footnotes in HTML

In traditional HTML, footnotes require the author to manually:

• Insert a superscript reference number at the point of citation.
• Maintain a matching numbered list at the bottom of the page.
• Keep both in sync whenever content is edited or reordered.
• Renumber all footnotes if one is inserted or removed.

This manual process is error-prone and time-consuming, especially in documents with many footnotes or frequent revisions.

The XML/XSL Solution

Using DocBook XML elements, a footnote is embedded directly inline at the point of reference in the XML content file:

The footnote text is placed inside a <footnote> element right where it is cited. The XSL stylesheet then automatically:

Assigns sequential numbers to all footnotes using xsl:number.
Inserts the superscript reference at the citation point.
Collects all footnote texts and renders them at the bottom of the page in order.
Renumbers automatically whenever footnotes are added, removed, or reordered in the XML.

The author never deals with numbering or positioning — the XSL handles everything consistently on every page.

The code is fully commented and free to download and adapt for your own use (retain the copyright notice at the top of each file).

← Back to Code Samples    Continue to Tables →