Footnotes

Here's one approach to including footnotes on HTML pages and insuring that they are properly numbered and positioned at the bottom of the appropriate pages -- regardless of how many HTML pages the XML document produces or how many footnotes it contains. It's a three-step process involving structuring the XML document properly, creating the XSL templates matches to format the footnotes correctly, and applying the XSL templates correctly at the bottom of the HTML Pages.


Step 1. Stucturing the XML Document

The XML sample adheres to the DocBook standard in which a footnote is simply enclosed within a <footnote> element. The label attribute identifies the desired footnote mark; in the sample below, the label marks the footnote with the number 1.

				
<para>If you've never heard the term e-government, you're not alone. 
In a poll conducted last year for the Council for Excellence in 
Government, only 34 percent of citizens were familiar with electronic 
government (e-government). The poll also indicated that 70 percent 
of Americans think tax dollars should be invested in improving 
access to government services.  <footnote label="1"> Council for 
Excellence in Government, <emphasis role="italics"> E-Government: 
To Connect, Protect, and Serve Us</emphasis> (2002), 
at http://www.excelgov.org/techcon/0225poll/report.PDF. </footnote> 
</para>
			

Step 2. Creating the XSL Template Matches

Because a footnote appears in two ways on a page -- first, as a marker in the text where the footnote is cited, and second, as a full text explanation of the note at the bottom of the page -- two XSL template matches are needed to format the footnote. The first one below -- <xsl:template match="footnote"> -- extracts the label attribute from the footnote element and displays it as a superscript at the place in the text where the footnote occurs. Note that this template only displays the footnote label (in this example, it would be the number 1), not the text of the footnote. The second template match -- <xsl:template match="footnote" mode="fulltext"> -- displays the footnote label along with the full text of the footnote. Note that this template match contains a mode attribute. This mode attribute will be used in the next step of applying the template to the HTML page.


<xsl:template match="footnote">
 <sup><xsl:value-of select="@label"/></sup>
</xsl:template> 
  		
<xsl:template match="footnote" mode="fulltext">
 <div class="ctcoltxt11">						 
  <sup><xsl:value-of select="@label"/></sup>
  <xsl:apply-templates /><br />
 </div>
</xsl:template>

			

Step 3. Applying the XSL Templates

The XSL code shown below would be invoked at the bottom of an HTML page and positioned between the end of the main text and any recurring footer information. The if condition checks to see if any footnotes were encountered on the page. If so, it draws a horizontal line to separate the footnotes from the main text body and then applies the footnote template in the fulltext mode defined in step 2 above.


<xsl:if test="para//footnote">
	<hr width="200" size="1" align="left"/>
	<xsl:apply-templates select="para//footnote" mode="fulltext"/>
</xsl:if>

			

Sample Web Page with Footnote

A Web page with footnotes formatted and processed by the XML/XSL file above would appear like the sample shown below.

Sample Web Page with footnotes