Endnotes

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.

Input TEI
...Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse faucibus. Nulla a tortor id pede aliquam venenatis. Donec eget lectus. Fusce hendrerit, quam ac nonummy rutrum, turpis odio ultrices tortor...

Output XHTML 1.0 (Strict)
At the insertion point:

...Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  [ 1]  Fusce hendrerit, quam ac nonummy rutrum, turpis odio ultrices tortor...

Elsewhere in the document

Notes:

Suspendisse faucibus. Nulla a tortor id pede aliquam venenatis. Donec eget lectus.

Create note section
The following template should be called (using ) 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,  , or. To avoid problems with  elements elsewhere in the tei document (e.g. in tei:teiHeader/notesStmt), the following can be substituted for the first   test:  :

  Notes:     

Build reference marker and link at insertion point
    refpoint-</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> [ <xsl:value-of select="normalize-space($notenum)"/> ] </a> <xsl:text> </xsl:text> </xsl:template>

Output note content at desired location
 <xsl:variable name="notenum" select="count(preceding::note[ancestor::text])+1"/> <xsl:variable name="linklabel" select="normalize-space($notenum)"/> <xsl:if test="p[position=1]">  <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> [      <xsl:value-of select="$notenum"/> ]        </a><xsl:text>. </xsl:text> <xsl:apply-templates select="p[position=1]"/> </xsl:if> <xsl:for-each select="p[not(position=1)]"> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:template>