I haven't gone back to the spec or the code, but assuming 1) that an only page is also both first and last, and 2) that isOnlyPage tells the truth about the page being tested, the problem seems to be with the
if (isOnlyPage) {...}
test. Shouldn't it be
 if (isOnlyPage) {
     if ( ! ( pagePosition == EN_ONLY
               || pagePosition == EN_FIRST
               || pagePosition == EN_LAST ) ) {
         return false;

--- Comment #7 from Dave Gerdt <[EMAIL PROTECTED]>  2008-07-08 13:59:23 PST ---
Looking for a solution to this first page/last page problem I found a potential
solution written by Ken Holman [1]. I assumed because he used it (and he seems
to know a little about the subject ;)  ) I had found my solution. (I hadn't
discovered this bug yet...)

However, the solution he provides doesn't work with FOP because as Simon points
out above "ConditionalPageMasterReference.isValid(isOddPage, isFirstPage,
isLastPage,isBlankPage) ... says explicitly that a conditional pagemaster
reference with page-position="last" is not valid for a first page." Looking at
the spec [2][3] I can't see any reason why that should be the case, though I'm
no expert in the spec, to be sure. Can one of the devs comment on this?

As a fix, I reordered the if statement in
ConditionalPageMasterReference.isValid so that the block for isLastPage comes
before the block for isFirstPage and removed 'return false' when pagePosition
== EN_FIRST in the isLastPage block (see code below). This appears to fix the
problem, at least for Ken's test file. Anyone see where this might blow up in
my face somewhere else? I ran the test suite and everything seemed to come out

The test case is attached.

[1] http://services.renderx.com/lists/xep-support/3856.html
[3] http://www.w3.org/TR/2001/REC-xsl-20011015/slice7.html#page-position

Reordered 'if' from ConditionalPageMasterReference.isValid:
if (isOnlyPage) {
    if (pagePosition != EN_ONLY) {
        return false;
} else if (isLastPage) {
    if (pagePosition == EN_REST) {
        return false;
    } else if (pagePosition == EN_FIRST) {
        //return false;
} else if (isFirstPage) {
    if (pagePosition == EN_REST) {
        return false;
    } else if (pagePosition == EN_LAST) {
        return false;
} else {
    if (pagePosition == EN_FIRST) {
        return false;
    } else if (pagePosition == EN_LAST) {
        return false;

Peter B. West <http://cv.pbw.id.au/>
Folio <http://defoe.sourceforge.net/folio/>

Reply via email to