Footnotes

1. xsl-fo cross references
2. Counting Footnotes
3. Seperating footnotes from body text
4. How do footnotes work?

1.

xsl-fo cross references

G. Ken Holman



>I made an <xref> element with an "idref" attribute in my DTD. Then some
>block elements have "id" attributes. I thought this would be handy when I
>do cross-references, like in:
>
><p>Read more about Iraq on page <xref idref="iraq"/>.</p>
>
>I'm trying to implement an <xref> template in XSL-FO now, but with no luck
>so far. I don't know how to extract the page number on the other page.

Where you process your <p id="iraq"> use:

   <block id="{generate-id(.)}"> .....

Where you process your <xref idref="iraq"/> use:

   <page-number-citation ref-id="{generate-id(id(@idref))}"/>

2.

Counting Footnotes

Jeni Tennison


> I have some XML which contains footnotes, these are in the style
> <footnote>something</footnote> they can appear anywhere in the
> source tree. I can create a link to them no problem (the documents
> root element I push twice, once for the main body, and again with a
> mode="footnote" to write out the footnotes out at the bottom of the
> document. However, footnotes are usually numbered, I would like to
> be able to number each footnote, in the text, and place the
> corresponding number at the bottom of the text next to the footnote.

Use xsl:number with level="any" to number the footnotes in the main text, e.g.:

<xsl:template match="footnote">
  <a href="..."><xsl:number level="any" /></a>
</xsl:template>

With level="any", xsl:number numbers nodes according to their position amongst any of the same type of (and name of) node within the document.

However, when you're actually outputting the footnotes, it will be more efficient if you apply templates directly to all the footnotes at once and use their position to number them:

<xsl:template match="/*" mode="footnote">
  <xsl:apply-templates select="//footnote" mode="footnote" />
</xsl:template>

<xsl:template match="footnote" mode="footnote">
  <a name="..."><xsl:value-of select="position()" /></a>
  <xsl:apply-templates />
</xsl:template>

This is because xsl:number forces the XSLT processor to look at all the preceding and ancestor nodes of each footnote - a lot of traversals. Collecting all the footnotes together and going through them in sequence saves the processor scrabbling all over the tree.

You can use the value attribute of xsl:number to format the position() in the same way as you use it to format the number it generates, e.g.:

  <xsl:number level="any" format="[a]" />
  ...
  <xsl:number value="position()" format="[a]" />

3.

Seperating footnotes from body text

David Tolpin



> I'd like to have a leader separating the body from the
> footnotes, like:

>   This is some text in the flow.
>   -------
>   1. First footnote.
>   2. Second footnote.

> I have a <footnote> element (inline) and a matching template in the XSL,
> but if I put the leader there there will be leaders between each footnote
> of course.

this is simple and standard.

<fo:static-content flow-name="xsl-footnote-separator">
  <fo:block>
   <fo:leader leader-pattern="rule" 
    leader-length="100%" rule-thickness="0.5pt" 
    rule-style="solid" color="black"/>
  </fo:block>
  </fo:static-content>

 

4.

How do footnotes work?

Ken Holman

Try the following example


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [
<!ENTITY page-width    "210mm">
<!ENTITY page-height   "297mm">
<!ENTITY margin-top    "15mm">
<!ENTITY margin-bottom "15mm">
<!ENTITY margin-left   "15mm">
<!ENTITY margin-right  "15mm">
<!ENTITY before-extent "13mm">
<!ENTITY after-extent  "13mm">
 ]>
<root font-family="Times" font-size="20pt"
         xmlns="http://www.w3.org/1999/XSL/Format">

<layout-master-set>
  <simple-page-master master-name="frame"
    page-height="&page-height;" page-width="&page-width;"
    margin-top="&margin-top;" margin-bottom="&margin-bottom;"
    margin-left="&margin-left;" margin-right="&margin-right;">
    <region-body region-name="frame-body"
      margin-top="&before-extent;" margin-bottom="&after-extent;"/>
    <region-after extent="&after-extent;"/>
  </simple-page-master>
</layout-master-set>

<page-sequence master-reference="frame">

<static-content flow-name="xsl-region-after">
  <block text-align="center"><page-number/></block>
</static-content>
<static-content flow-name="xsl-footnote-separator">
  <block font-style="italic">Footnotes</block>
</static-content>

<flow flow-name="frame-body" font-size="40pt">
<block>This is a test</block>
<block>This is a<footnote>
<inline baseline-shift="15pt" font-size="20pt">1</inline>
<footnote-body>
  <block font-size="20pt">
    <inline baseline-shift="5pt" font-size="15pt"
      >1 </inline>This is a footnote with a very
long paragraph so that it will (hopefully) wrap onto
multiple lines in the footnote area.
  </block>
</footnote-body>
</footnote> test</block>
<block>This is a test</block>
<block>This is a<footnote>
<inline baseline-shift="15pt" font-size="20pt">2</inline>
<footnote-body>
  <block font-size="20pt">
    <inline baseline-shift="5pt" font-size="15pt"
      >2 </inline>This is another footnote, once
again with a very long paragraph so that it will
(hopefully) wrap onto multiple lines in the footnote area.
  </block>
</footnote-body>
</footnote> test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>
<block>This is a test</block>

</flow>

</page-sequence>

</root>