End notes

There is no stylesheet parameter that converts footnotes to endnotes, but it can be done with a customization. Take a look at the template with match="footnote" in fo/footnote.xsl, for example. You can customize that to generate endnotes.

First copy the template to your customization layer and remove the fo:footnote elements, because they generate bottom-of-page footnotes. Leave just the part that generates the footnote number, inside an fo:inline:

<xsl:template match="footnote">
  <fo:inline>
    <xsl:call-template name="format.footnote.mark">
      <xsl:with-param name="mark">
        <xsl:apply-templates select="." mode="footnote.number"/>
      </xsl:with-param>
    </xsl:call-template>
  </fo:inline>
</xsl:template>

Then add a template with a new mode="endnote" like the following to format each footnote:

<xsl:template match="footnote" mode="endnote">
  <fo:block xsl:use-attribute-sets="footnote.properties">
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>

The footnote mark is included when doing apply-templates to a footnote element. Then you can generate the list of end notes by putting a template like the following in your customization layer. It is meant to be called at the end of each chapter or appendix.

<xsl:template name="make.endnotes.list">
    <xsl:apply-templates mode="endnote"
                         select="ancestor-or-self::chapter//footnote |
                                 ancestor-or-self::appendix//footnote"/>
</xsl:template>

This will select and process all the footnotes in the current chapter or appendix, in document order. If you are putting all your end notes at the end of a book, you should use select="//footnote" instead. You will also want to turn off the way each chapter restarts the footnote number sequence, by customizing the template that starts with the following line:

<xsl:template match="footnote" mode="footnote.number">

The only remaining item is figuring out how to call the make.endnotes.list template at the point where you want the list of end notes to appear. If you want them at the end of the book, you will have to customize the template with match="book". You'll need to create a new page-sequence, add a title, and call the make.endnotes template inside the page-sequence.

If you want end notes to appear at the end of each chapter, you can customize the end of the template with match="chapter" from fo/component.xsl as follows:

<xsl:template match="chapter">
      [first part of the template]
      ...
      <xsl:apply-templates/>

      <xsl:if test="descendant::footnote">
        <fo:block space-before="44pt" font-weight="bold"
                  font-size="14pt" font-family="{$title.fontset}">
          <xsl:text>Endnotes</xsl:text>
        </fo:block>
        <fo:block >
          <xsl:call-template name="make.endnotes.list"/>
        </fo:block>
      </xsl:if>
    </fo:flow>
  </fo:page-sequence>
</xsl:template>

It tests to see if the current chapter has any footnote elements. If so, it outputs a title and calls make.endnotes.list.

If you are generating end notes instead of footnotes, you might want to turn off the ulink.footnotes parameter (it is zero by default).