docbook-apps

  • 1.  Re: [docbook-apps] endnotes section in ePub

    Posted 07-18-2011 22:22
    Hi Jason,
    Here is a quick summary of an approach, untested.

    1. You can start by copying the template with match="d:appendix" from component.xsl
    to your customization layer and changing the match attribute to add the role
    qualifier. That template will give you the basic elements and title processing.

    2. Replace <xsl:apply-templates/> with <xsl:call-template name="process.endnotes"/>

    3. Copy the template named 'process.footnotes' from footnote.xsl to your
    customization, renaming it to 'process.endnotes'.

    4. Modify process.endnotes to replace:

    <xsl:variable name="footnotes" select=".//d:footnote"/>

    with:

    <xsl:variable name="footnotes" select="//d:footnote"/>

    Removing the leading dot in the select statement converts it from selecting footnotes
    only as descendants of the current element to descendants of the root element.

    I didn't have a chance to test this, but it should get you started.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





  • 2.  RE: [docbook-apps] endnotes section in ePub

    Posted 07-19-2011 20:17
    Thanks again, Bob. I've managed to get it up and running, and it looks great.

    There is one issue left for me to resolve: by default the footnotes/endnotes are creating links using only IDs (since it presumes you'll be linking within the same doc), but in epub with endnotes, the links need to go across different HTML files. I've managed to fix this in the links TO the endnotes page (just added endnotes filename to the href attribute, since the footnotes will always lead OUT to the same endnotes file).

    <xsl:template match="d:footnote">
    ...


    What I'm unable to do now is figure out how to have the processor generate the HREF for the returning links so that it includes the appropriate filename before the #id. Any advice? I can't seem to find a variable to plug in that carries the filename. Am I going in the right direction here?

    <xsl:template match="*" mode="footnote.body.number">
    <xsl:variable name="name">
    <xsl:text>ftn.</xsl:text>
    <xsl:call-template name="object.id">
    <xsl:with-param name="object" select="ancestor::d:footnote"/>
    </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="href">
    <xsl:text>#</xsl:text>
    <xsl:call-template name="object.id">
    <xsl:with-param name="object" select="ancestor::d:footnote"/>
    </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="footnote.mark">

    <xsl:text>[</xsl:text>

    <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:apply-templates select="ancestor::d:footnote" mode="footnote.number"/>

    <xsl:text>]</xsl:text>

    </xsl:variable>

    <xsl:variable name="html">
    <xsl:apply-templates select="."/>
    </xsl:variable>

    <xsl:choose>
    <xsl:when test="$exsl.node.set.available != 0">
    <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
    <xsl:choose>
    <xsl:when test="$html-nodes//p">
    <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
    <xsl:with-param name="mark" select="$footnote.mark"/>
    </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
    <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
    <xsl:with-param name="mark" select="$footnote.mark"/>
    </xsl:apply-templates>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$html"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>