xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Van den Branden <ron.vandenbran...@kantl.be>
Subject alleviation of footnote-inside-list/table rendering problem
Date Tue, 12 Feb 2008 09:59:19 GMT
Hi,

Today I stumbled upon the issue with footnotes that get swallowed inside 
list items and table cells. Searching the mailing list archives I 
(re)discovered that this is a well known issue 
(<http://xmlgraphics.apache.org/fop/knownissues.html>), formally 
documented as a bug at 
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37579>). From the 
comments in the bug tracker, it seems that a) the bug won't be resolved 
for anytime soon and b) there's no known workaround. However, since I 
think I found a way of circumventing (or at least alleviating - see 
bottom remark) the problem (at stylesheet level; not at Java code 
level), I want to share it here for other XSL-FO strugglers as well.

(At first, I thought I had found a way around the issue already, from 
previous work with Fop-0.20-5. If I recall correctly, that version did 
render footnotes inside lists and certainly tables, but caused the text 
of end-of-page lists to flow over the footnote text at the bottom of the 
page. This could be 'fixed' by avoiding fo:list-block all the way. 
However, this approach definitely doesn't work anymore with Fop-0.94+, 
which 'swallows' fo:footnote content inside fo:list-block and fo:table.)

A way in which the problem can be avoided, is by generating fo:footnote 
areas for those footnotes *outside* the areas of their containing lists 
and tables. If those fo:footnote areas don't contain any text in their 
fo:inline footnote markers, the latter don't show up in the inline text, 
while the fo:footnote-body does end up in the footnote region at the 
bottom of the page. [Note: this use of footnotes is inspired by 
solutions to other vertical alignment issues like 
<http://www.dpawson.co.uk/xsl/sect3/fofixedposn.html#d12878e43>]
Stylesheet-wise this involves a two-way treatment of footnotes inside 
lists and tables: 1) generate the footnote markers inline (just a 
fo:inline containing the footnote marker suffices), 2) generate the 
fo:footnote areas for each of those footnotes out-of-line, inside a 
fo:block after the affected fo:list-block / fo:table.

I'll illustrate with following code, in which the first footnote doesn't 
get rendered, while the second one does:

    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simple" page-height="5in" 
page-width="5in">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simple">
        <fo:flow flow-name="xsl-region-body">
          <fo:list-block provisional-distance-between-starts="50pt" 
provisional-label-separation="10pt">
            <fo:list-item>
              <fo:list-item-label end-indent="label-end()">
                <fo:block>label</fo:block>
              </fo:list-item-label>
              <fo:list-item-body start-indent="body-start()">
                <fo:block>
                  <!-- This fo:block contains a 'regular' fo:footnote 
inside a fo:list-block. Note that the fo:footnote-body
                          doesn't get rendered in the output, due to bug 
37579
                          
(http://issues.apache.org/bugzilla/show_bug.cgi?id=37579) -->
                  List item with a footnote<fo:footnote>
                  <fo:inline font-size="60%" 
baseline-shift="super">1)</fo:inline>
                    <fo:footnote-body>
                      <fo:block start-indent="0.5cm" text-indent="-0.5cm">
                        <fo:inline font-size="60%" 
baseline-shift="super">1)</fo:inline> This footnote doesn't get 
rendered.</fo:block>
                    </fo:footnote-body>
                  </fo:footnote>.
                </fo:block>
              </fo:list-item-body>
            </fo:list-item>
            <fo:list-item>
              <fo:list-item-label end-indent="label-end()">
                <fo:block>label</fo:block>
              </fo:list-item-label>
              <fo:list-item-body start-indent="body-start()">
                <fo:block>
                  <!-- this footnote is only marked inline by a 
fo:inline marker -->
                  List item with a footnote<fo:inline font-size="60%" 
baseline-shift="super">2)</fo:inline>.
                </fo:block>
              </fo:list-item-body>
            </fo:list-item>           
          </fo:list-block>
          <!-- this block contains the fo:footnote areas for all 
separate footnotes in the previous fo:list-block -->
          <fo:block>
            <fo:footnote>
              <!-- this fo:inline footnote marker is empty to avoid it 
getting output after the fo:list-block -->
              <fo:inline/>
              <fo:footnote-body>
                <fo:block start-indent="0.5cm" text-indent="-0.5cm">
                  <fo:inline font-size="60%" 
baseline-shift="super">2)</fo:inline> This footnote does get 
rendered.</fo:block>
                </fo:footnote-body>
              </fo:footnote>
            </fo:block>
          </fo:flow>
        </fo:page-sequence>
      </fo:root>

Note that this approach will require some refinements. For example, for 
lists / tables that span multiple pages, the footnotes will all end up 
before / after the affected list / table (depending on the placement of 
their containing block). In order to avoid this, the fo:list-block / 
fo:table areas could be generated at the lower level of the list items, 
i.e. the input list / table will not generate a fo:list-block / 
fo:table, but each list item / table row will. Each of those 
fo:list-block / fo:table areas can then be followed by a fo:block 
containing the relevant fo:footnote area. Of course this produces a lot 
of one-item lists / one-row tables, but it also guarantees that 
footnotes will show at the right page when they occur in long lists / 
tables. I haven't tested it in my production XSL-FO stylesheets, and of 
course treatment of nested lists would demand further consideration, but 
I think the principle works.

Maybe I'm just stating the obvious (and apologies if I'm stealing 
others' ideas), but since I couldn't find any reference to this approach 
in the mailing list, I thought it could be useful for others as well. 
I'm open for any comments or remarks.

Ron Van den Branden
www.kantl.be/ctb

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message