You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Joerg Pietschmann <jo...@zkb.ch> on 2002/05/08 11:13:20 UTC

Precedence of page masters

Hi gurus,
while checking the test case bug 3379, I noticed the following
construct:

 <fo:page-sequence-master master-name="TOC">
   <fo:repeatable-page-master-alternatives>
     <fo:conditional-page-master-reference
        blank-or-not-blank="blank" master-reference="blank-page" />
     <fo:conditional-page-master-reference
        odd-or-even="odd" master-reference="bare-page-right" />
     <fo:conditional-page-master-reference
        odd-or-even="even" master-reference="bare-page-left" />
   </fo:repeatable-page-master-alternatives>
 </fo:page-sequence-master>

There appears to be two masters applicable for blank pages,
because a blank page has to be necessarily either an odd or
an even page. FOP uses the blank-page master anyway, and this
is quite intuitive in this case, but I couldn't find a passage
in the spec which states what to do if more than one of the
conditional page masters apply (6.4.11
fo:conditional-page-master-reference appears to be the place
to start a search).
For example, what happens here:

 <fo:page-sequence-master master-name="TOC">
   <fo:repeatable-page-master-alternatives>
     <fo:conditional-page-master-reference
        blank-or-not-blank="blank" master-reference="general-blank-page" />
     <fo:conditional-page-master-reference
        odd-or-even="odd" blank-or-not-blank="blank"
        master-reference="odd-blank-page" />
     <fo:conditional-page-master-reference
        odd-or-even="even" master-reference="even-regular-page" />
     <fo:conditional-page-master-reference
        master-reference="general-page" />
   </fo:repeatable-page-master-alternatives>
 </fo:page-sequence-master>

The other problem is if the set of alternatives does not cover
all possible combinations, for example there are only masters
for blank pages. The spec doesn't say anything special about this,
the general rules (6.4.7) appear to be applicable, and in case
a blank page is encountered, the master of the page before should
be used. This is somewhat problematic if the blank page is the
first page rendered. Anyway, FOP always falls over with a NPE.

There is also a neat buglet related to this: The following
declaration, often seen, is also incomplete:
 <fo:page-sequence-master master-name="TOC">
   <fo:repeatable-page-master-alternatives>
     <fo:conditional-page-master-reference
        page-position="first" master-reference="first" />
     <fo:conditional-page-master-reference
        page-position="rest" master-reference="other" />
   </fo:repeatable-page-master-alternatives>
 </fo:page-sequence-master>
because the "rest" master does not apply to the last page.
FOP does the right thing by reusing the "rest" master except
in the situation where only two pages are rendered, in which
case the "first" page master should have been used. Duh!
And of course, there is no user notification.

Conclusion: should we request clarification from the standards
committee (or has this already been done?) or just document
how FOP handles such situations?
The case of emitting a sensible error message in case of an
incomplete master set is on my ToDo list, but way down. I'll
open a new bug if I don't find anything applicable in bugzilla.

Regards
J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


RE: Precedence of page masters

Posted by Arved Sandstrom <Ar...@chebucto.ns.ca>.
Hi, Joerg

Conditional-page-master-references (CPMRs) are checked in document order.
This is specified in Section 6.4.10, Constraints, clause (d).

More below.

> -----Original Message-----
> From: Joerg Pietschmann [mailto:joerg.pietschmann@zkb.ch]
> Sent: May 8, 2002 6:13 AM
> To: FOP Dev
> Subject: Precedence of page masters
>
[ SNIP ]
>
> The other problem is if the set of alternatives does not cover
> all possible combinations, for example there are only masters
> for blank pages. The spec doesn't say anything special about this,
> the general rules (6.4.7) appear to be applicable, and in case
> a blank page is encountered, the master of the page before should
> be used. This is somewhat problematic if the blank page is the
> first page rendered. Anyway, FOP always falls over with a NPE.

You're right, it's possible for none of the CPMRs to apply, in which case
the repeatable-page-master-alternatives (RPA) should be terminated in that
page-sequence-master (PSM), _not_ to be re-used in that page-sequence. The
termination follows from constraint (b) in 6.4.10.

One should then move on to the next master-reference in the PSM; if the RPMA
_was_ the last then in theory FOP _may_ re-use the RPMA, but we have already
established that the RPMA matches no page in this situation, so this should
be caught as a user error and the formatter should stop processing the
page-sequence. My opinion.

I should have caught this when I worked on the code. An NPE is not very
helpful. :-)

> There is also a neat buglet related to this: The following
> declaration, often seen, is also incomplete:
>  <fo:page-sequence-master master-name="TOC">
>    <fo:repeatable-page-master-alternatives>
>      <fo:conditional-page-master-reference
>         page-position="first" master-reference="first" />
>      <fo:conditional-page-master-reference
>         page-position="rest" master-reference="other" />
>    </fo:repeatable-page-master-alternatives>
>  </fo:page-sequence-master>
> because the "rest" master does not apply to the last page.
> FOP does the right thing by reusing the "rest" master except
> in the situation where only two pages are rendered, in which
> case the "first" page master should have been used. Duh!
> And of course, there is no user notification.

It's really a user error if an RPMA is supplied that does not cover all
potential pages. I think we can put in code that when the RPMA is set up, it
does a page coverage check and alerts the user as required.

A person _could_ put in an RPMA and they don't supply a
page-position='last', say, because they definitely know that because of a
maximum-repeats that the RPMA will not get used for the "last" page, _and_
they have at least one other applicable page-master-reference succeeding the
RPMA, and we could skip the alert in this case.

> Conclusion: should we request clarification from the standards
> committee (or has this already been done?) or just document
> how FOP handles such situations?
> The case of emitting a sensible error message in case of an
> incomplete master set is on my ToDo list, but way down. I'll
> open a new bug if I don't find anything applicable in bugzilla.
>
> Regards
> J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org