You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Ron Van den Branden <ro...@kantl.be> on 2008/02/12 10:59:19 UTC

alleviation of footnote-inside-list/table rendering problem

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


Re: alleviation of footnote-inside-list/table rendering problem

Posted by Fyodor <fy...@insecure.org>.
On Mon, 10 Mar 2008 17:00:18 +0100, Ron Van den Branden wrote:
> In a post to this list a couple of weeks ago, I hinted at a way in
> which FOP bug #37579
> (<http://issues.apache.org/bugzilla/show_bug.cgi?id=37579>), which
> causes omission of footnotes inside tables or lists could be
> circumvented. Thanks to Andreas, this has been added as a comment to
> the formal bug description as well.
>
> In the mean time, I have investigated this approach further, and 
> documented this research in a blog post at <http://rvdb.wordpress.com/>. 
> It describes how far it got me in circumventing the bug and indicates 

Thanks for posting.  This bug has been open for about 2.5 years, so it
is great to see progress made.  I'm glad to have your workaround as an
option, but we'd all really like to see the FOP code updated to handle
this itself.  Unfortunately, my FOP skills are rather poor.  Does
anyone here have ideas as to the best way to fix this?  I'm writing a
book documenting Free Software (the Nmap Security Scanner), so my goal
is to create the book using only Free Software.

Cheers,
Fyodor


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


Re: alleviation of footnote-inside-list/table rendering problem

Posted by Ron Van den Branden <ro...@kantl.be>.
Hi all,

In a post to this list a couple of weeks ago, I hinted at a way in which 
FOP bug #37579 
(<http://issues.apache.org/bugzilla/show_bug.cgi?id=37579>), which 
causes omission of footnotes inside tables or lists could be 
circumvented. Thanks to Andreas, this has been added as a comment to the 
formal bug description as well.

In the mean time, I have investigated this approach further, and 
documented this research in a blog post at <http://rvdb.wordpress.com/>. 
It describes how far it got me in circumventing the bug and indicates 
where problems remain. It also provides a link to a downloadable zip 
package containing sample source XML documents and an XSLT stylesheet 
implementing the techniques discussed. I hope this can a) help others 
looking for a solution to this problem and b) lead to a better solution. 
Comments are welcome!

Kind regards,

Ron

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


Re: alleviation of footnote-inside-list/table rendering problem

Posted by Andreas Delmelle <an...@telenet.be>.
On Feb 12, 2008, at 10:59, Ron Van den Branden wrote:

Hi Ron

> Today I stumbled upon the issue with footnotes that get swallowed  
> inside list items and table cells.
<snip />
> , 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.

Always a good idea. I think this will indeed be useful. I've added  
your suggestion to the Bugzilla report, so other interested parties  
immediately see a workaround as long as the implementation is  
incomplete.

Thanks for the contribution!


Cheers

Andreas

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