Code for Essay.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink"
exclude-result-prefixes="xlink">
<!-- ****************************************************** -->
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="Essay/head/title"/>
</title>
</head>
<body>
<xsl:apply-templates/>
<br/>
<hr/>
<br/>
Back to the XML/XSL section
<br/>
<img align="bottom" src="../hand-r.gif"/>
<a href="xml_section.html">
<img align="bottom" src="../exit.gif"/>
</a>
<p>
<hr/>
<br/>
</p>
<font size="-1">
<!-- some statement regarding the document's
XML/HTML/XHTML/ validity with respect to some DTD. -->
</font>
</body>
</html>
</xsl:template>
<!-- ****************************************************** -->
<!-- ***** Format Essay/head/title and Essay/head/subtitle. Ignore the
Essay/head/author element -->
<xsl:template match="Essay/head">
<div>
<font face="Helvetica">
<h3>
<xsl:apply-templates select="title/alphanum"/>
<xsl:apply-templates select="subtitle/alphanum"/>
</h3>
</font>
<img align="middle" src="../aqualine.gif"/>
<div>
<br/>
</div>
</div>
</xsl:template>
<!-- ****************************************************** -->
<!-- **** Format Essay/intro. -->
<xsl:template match ="Essay/intro">
<xsl:apply-templates/>
<br/>
</xsl:template>
<!-- ****************************************************** -->
<!-- **** Format Essay/body. -->
<xsl:template match ="Essay/body">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match ="Essay/body/section">
<div>
<xsl:apply-templates/>
<br/>
</div>
</xsl:template>
<xsl:template match="Essay/body/section/heading">
<font face="Arial">
<xsl:choose>
<xsl:when test="@level='one'">
<h4>
<xsl:value-of select="text"/>
</h4>
</xsl:when>
<xsl:when test="@level='two'">
<h5>
<xsl:value-of select="text"/>
</h5>
</xsl:when>
<xsl:when test="@level='three'">
<h6>
<xsl:value-of select="text"/>
</h6>
</xsl:when>
</xsl:choose>
</font>
</xsl:template>
<xsl:template match="paragraph">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="text">
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="alphanum">
<font face="TimesNewRoman">
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</font>
</xsl:template>
<xsl:template match="footnote">
<font face="TimesNewRoman">
<sup>
<b><xsl:number level="any" count="footnote"/></b>
</sup>
</font>
</xsl:template>
<xsl:template match="citation">
<font face="TimesNewRoman">
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</font>
</xsl:template>
<xsl:template match="crossref">
<font face="TimesNewRoman">
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</font>
</xsl:template>
<xsl:template match="emph">
<i>
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</i>
</xsl:template>
<xsl:template match="code">
<font face="Courier">
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</font>
</xsl:template>
<xsl:template match="formula">
<font face="Courier">
<xsl:choose>
<xsl:when test="@xlink:type='simple' and @xlink:href">
<a href="{@xlink:href}">
<xsl:apply-templates/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</font>
</xsl:template>
<xsl:template match="subscript">
<font face="Courier" size="-1">
<sub><xsl:apply-templates/></sub>
</font>
</xsl:template>
<!-- breaking the rules of good XML DTD construction? I could argue both
sides. The fact is, I need bold and pre. -->
<xsl:template match="bold">
<b>
<xsl:apply-templates/>
</b>
</xsl:template>
<xsl:template match="pre">
<pre>
<xsl:apply-templates/>
</pre>
</xsl:template>
<xsl:template match="graphic">
<xsl:apply-templates select="figure"/>
<xsl:apply-templates select="table"/>
<xsl:apply-templates select="graphic_title"/>
</xsl:template>
<xsl:template match="figure">
<span>
<embed src="{@fileref}" height="{@height}" width="{@width}"/>
<div>
<br/>
</div>
<font face="Helvetica" size="-1">
Figure <xsl:number level="any" count="figure"/>.
</font>
</span>
</xsl:template>
<xsl:template match="table">
<table border="2" cellpadding="10" cellspacing="2">
<tr valign="top">
<xsl:for-each select="header_row/col_head">
<td><font face="Arial" size="-1">
<xsl:value-of select="text"/>
</font></td>
</xsl:for-each>
</tr>
<xsl:for-each select="row">
<tr valign="top">
<xsl:for-each select="row_item">
<td><font face="Arial" size="0">
<xsl:value-of select="text"/>
</font></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
<div>
</div>
<font face="Helvetica" size="-1">
Table <xsl:number level="any" count="table"/>.
</font>
</xsl:template>
<xsl:template match="graphic_title">
<font face="Helvetica" size="-1">
<xsl:value-of select="text"/>
</font>
<br/>
</xsl:template>
<xsl:template match="list">
<xsl:if test="@sequence='unordered'">
<ul>
<xsl:for-each select="item">
<li>
<xsl:apply-templates/>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test="@sequence='ordered'">
<ol>
<xsl:for-each select="item">
<li>
<xsl:apply-templates/>
</li>
</xsl:for-each>
</ol>
</xsl:if>
</xsl:template>
<!-- ****************************************************** -->
<!-- **** Format Essay/tail. -->
<xsl:template match ="Essay/tail">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match ="Essay/tail/notes">
<br/>
<hr/>
<font face="Helvetica"><h4>Notes</h4></font>
<xsl:for-each select="note_entry">
<b><sup><xsl:value-of select="@number"/>
</sup></b>
<xsl:value-of select="alphanum|citation|crossref"/>
<br/>
<br/>
</xsl:for-each>
</xsl:template>
<xsl:template match ="Essay/tail/bib">
<br/>
<hr/>
<font face="Helvetica"><h4>Bibliography</h4>
</font>
<xsl:apply-templates/>
<br/>
</xsl:template>
<xsl:template match ="Essay/tail/bib/bib_entry">
<xsl:value-of select="@bib_authors"/>,
<xsl:if test="@art_title">
<xsl:value-of select="@art_title"/>,
</xsl:if>
<i><xsl:value-of select="@bib_title"/></i>,
<xsl:if test="@art_title">
<xsl:value-of select="@addit_inf"/>,
</xsl:if>
(<xsl:value-of select="@pub_data"/>).
<br/>
<br/>
</xsl:template>
</xsl:stylesheet>