Difference between revisions of "Endnotes"
Jump to navigation
Jump to search
(Still in progress) |
|||
| Line 29: | Line 29: | ||
<div class="notes"> | <div class="notes"> | ||
<h2><a id="notes"/>Notes:</h2> | <h2><a id="notes"/>Notes:</h2> | ||
| + | <div class="footnote"><p> | ||
| + | <a id="note-1" href="#refpoint-1" title="Link to insertion point | ||
| + | of note in main text."><span class="hideme">[</span>1<span | ||
| + | class="hideme">]</span></a>. Suspendisse faucibus. | ||
| + | Nulla a tortor id pede aliquam venenatis.</p> | ||
| + | <p>Donec eget lectus.</p> | ||
| + | </div> | ||
| + | [other html:div[class='note']] | ||
| + | </div> | ||
| − | |||
| − | |||
| − | |||
| − | |||
==XSLT== | ==XSLT== | ||
===Create note section=== | ===Create note section=== | ||
| Line 95: | Line 100: | ||
</xsl:template> | </xsl:template> | ||
</pre> | </pre> | ||
| + | |||
| + | |||
| + | ==Limitations, assumptions, and quirks== | ||
| + | This xslt code is subject to the following limitations, assumptions, and quirks | ||
| + | |||
| + | #all tei:note elements must contain at least one tei:p (it is not hard to adjust the code for notes that contain CDATA, however. | ||
| + | #the note content is output to html:div rather than html:p, since each note is understood as a collection of paragraphs. | ||
Revision as of 15:36, 21 April 2005
This xslt transforms tei:note elements for display in xhtml. It places a numbered marker at the insertion point and reproduced the note content in a separate section at the end of the document. Links between the insertion marker and note are automatically generated.
Contents
Input TEI
<p>...Lorem ipsum dolor sit amet, consectetuer adipiscing elit.<note><p>Suspendisse faucibus. Nulla a tortor id pede aliquam venenatis.</p> <p>Donec eget lectus.</p></note> Fusce hendrerit, quam ac nonummy rutrum, turpis odio ultrices tortor...</p>
Output XHTML 1.0 (Strict)
At the insertion point:
<p>...Lorem ipsum dolor sit amet, consectetuer adipiscing elit.<sup><a name="refpoint-1" href="#note-1" title="Link to note 1 at the end of this document."><span class="hideme">[</span>1<span class="hideme">]</span></a></sup> Fusce hendrerit, quam ac nonummy rutrum, turpis odio ultrices tortor...</p>
Elsewhere in the document
<hr class="subdivider"/>
<div class="notes">
<h2><a id="notes"/>Notes:</h2>
<div class="footnote"><p>
<a id="note-1" href="#refpoint-1" title="Link to insertion point
of note in main text."><span class="hideme">[</span>1<span
class="hideme">]</span></a>. Suspendisse faucibus.
Nulla a tortor id pede aliquam venenatis.</p>
<p>Donec eget lectus.</p>
</div>
[other html:div[class='note']]
</div>
==XSLT==
===Create note section===
The following template should be called (using <code><xsl:call-template name="notessection"/></code>) at the point at which you wish the notes to appear in your output document. This will most likely be in the template for your document root <code>/</code>, <code>TEI.2</code>, or <code>text</code>. To avoid problems with <code>note</code> elements elsewhere in the tei document (e.g. in tei:teiHeader/notesStmt), the following can be substituted for the first <code><xsl:if</code> test: <code>body//note</code>:
<pre>
<xsl:template name="notessection">
<xsl:if test="note">
<hr class="subdivider"/>
<div class="notes">
<h2><a id="notes"/>Notes:</h2>
<xsl:for-each select=".//note">
<xsl:apply-templates select="." mode="shownotes"/>
</xsl:for-each></div>
</xsl:if>
</xsl:template>
Build reference marker and link at insertion point
<xsl:template match="text//note">
<xsl:variable name="notenum" select="count(preceding::note[ancestor::text])+1"/>
<xsl:variable name="linklabel" select="normalize-space($notenum)"/>
<sup><a>
<xsl:attribute name="name">refpoint-<xsl:value-of select="$linklabel"/></xsl:attribute>
<xsl:attribute name="href">#note-<xsl:value-of select="$linklabel"/></xsl:attribute>
<xsl:attribute name="title">Link to note <xsl:value-of select="$linklabel"/> at the end of this document.</xsl:attribute>
<span class="hideme">[</span><xsl:value-of select="normalize-space($notenum)"/><span class="hideme">]</span></a></sup>
<xsl:text> </xsl:text>
</xsl:template>
Output note content at desired location
<xsl:template match="text//note" mode="shownotes">
<xsl:variable name="notenum" select="count(preceding::note[ancestor::text])+1"/>
<xsl:variable name="linklabel" select="normalize-space($notenum)"/>
<div class="footnote">
<xsl:if test="p[position()=1]">
<p>
<a>
<xsl:attribute name="id">note-<xsl:value-of select="$linklabel"/></xsl:attribute>
<xsl:attribute name="href">#refpoint-<xsl:value-of select="$linklabel"/></xsl:attribute>
<xsl:attribute name="title"><xsl:text>Link to insertion point of note in main text.</xsl:text></xsl:attribute>
<span class="hideme">[</span>
<xsl:value-of select="$notenum"/>
<span class="hideme">]</span>
</a><xsl:text>. </xsl:text>
<xsl:apply-templates select="p[position()=1]"/>
</p>
</xsl:if>
<xsl:for-each select="p[not(position()=1)]">
<p>
<xsl:apply-templates select="."/>
</p>
</xsl:for-each>
</div>
</xsl:template>
Limitations, assumptions, and quirks
This xslt code is subject to the following limitations, assumptions, and quirks
- all tei:note elements must contain at least one tei:p (it is not hard to adjust the code for notes that contain CDATA, however.
- the note content is output to html:div rather than html:p, since each note is understood as a collection of paragraphs.