OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Better FO footnote symbols


Hey,

I had to rewrite the footnote symbol handler for work this morning to
comply with the Chicago Manual of Style 14e, 12.51. I don't really
like the way the current stylesheets eventually go for symbols to
numbers, so I'm sharing in hope that it might help somebody else (FO
only):

  <!-- Asterisk, Dagger, Double Dagger, Section Sign, Double Vertical
Line, Pound (then double each, triple each ...) -->
  <xsl:param name="footnote.number.symbols"
select="'*&#x2020;&#x2021;&#x00A7;&#x2016;#'"/>

helper, anywhere:
  <xsl:template name="dup">
    <xsl:param name="input"/>
    <xsl:param name="count" select="2"/>
    <xsl:choose>
      <xsl:when test="not($count) or not($input)"/>
      <xsl:when test="$count = 1">
        <xsl:value-of select="$input"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="$count mod 2"> <!-- it's odd -->
          <xsl:value-of select="$input"/>
        </xsl:if>
        <xsl:call-template name="dup">
          <xsl:with-param name="input" select="concat($input, $input)"/>
          <xsl:with-param name="count" select="floor($count div 2)"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

in fo/footnote.xsl:
<xsl:template match="footnote" mode="footnote.number">
  <xsl:choose>
    <xsl:when test="string-length(@label) != 0">
      <xsl:value-of select="@label"/>
    </xsl:when>
    <xsl:when test="ancestor::table or ancestor::informaltable">
      <xsl:variable name="tfnum">
        <xsl:number level="any" from="table|informaltable" format="1"/>
      </xsl:variable>
      <xsl:variable name="tfsymnum"
select="string-length($table.footnote.number.symbols)"/>
      <xsl:call-template name="dup">
        <xsl:with-param name="input"
select="substring($table.footnote.number.symbols, $tfnum mod
$tfsymnum, 1)"/>
        <xsl:with-param name="count" select="ceiling($tfnum div $tfsymnum)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="fnum">
        <!-- FIXME: list in @from is probably not complete -->
        <xsl:number level="any"

from="chapter|appendix|preface|article|refentry|bibliography"
                    count="footnote[not(@label)][not(ancestor::table)
and not(ancestor::informaltable)]|ulink[node()][@url !=
.][not(ancestor::
                    format="1"/>
                <!-- was
                    count="footnote[not(@label)][not(ancestor::table)
and not(ancestor::informaltable)]|ulink[$ulink.footnotes !=
0][node()][@u
                    -->
      </xsl:variable>
      <xsl:variable name="symnum"
select="string-length($footnote.number.symbols)"/>
      <xsl:call-template name="dup">
        <xsl:with-param name="input"
select="substring($footnote.number.symbols, $fnum mod $symnum, 1)"/>
        <xsl:with-param name="count" select="ceiling($fnum div $symnum)"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


Comments encouraged.


Keith


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]