Hi, Juliette...
To echo Ed (since the office we share isn't big enough for that to
happen on its own), I'm no XSL-FO expert, as we still use FOSI here.
I'm also not sure I completely understand your situation, but some of
your questions make me think you're not quite on the right track, so
I'll try to back up and fill in the gaps a bit, if I can. I apologize
if this is stuff you already know.
You mention a couple of times setting up a "condition statement" or an
"if/when" to handle things differently based on whether the foldout will
be an odd or even page. If you're talking about your XSLT, you won't be
able to do that. The XSLT transform is only responsible for
transforming your XML file, which generally uses "semantic" markup
(i.e., "this is an introduction", "this is an equipment list", "this is
a glossary entry", etc.) into page description markup (i.e., "this is a
paragraph", "this is a table", "this is a footnote", etc.). The
standard for page description markup that you're targeting is XSL-FO.
Another process, generally completely disconnected from the XSLT
processor, is responsible for taking that page description markup and
deciding where to put ink on paper as a result (or the virtual
equivalent of it, if you're making PDF without necessarily printing it
out).
Because the XSLT processor doesn't know how to decide where the pages
will break and generally has no means to ask the process that will make
that decision, your page description markup needs to describe the page
sequence in a way that will give the layout process all the information
it needs whether your foldout ends up on an odd page or an even one.
This is what the page-sequence stuff is all about. It specifies one or
more page layouts, the order they're used in and any conditions that
might need to be met in order to pick one layout over another at any
given point in the sequence.
Based on the snippet you provided, it appears that your publication
requires a contiguous series of foldouts to start on an odd-numbered
page. Given that odd-numbered pages are generally on the right-hand
(a.k.a. recto, or front) side, this makes sense, as you would be
switching to a new paper size at that point and could not just squeeze
the foldout onto the left-hand (a.k.a. verso, or back) side of a
different-sized sheet of paper. However, unless there is something
different about the layout of the first page in a series of foldouts,
you should not need a different page-master for this page, as it should
be perfectly legal to have the layout engine issue one instance of the
master as the "first" page and additional instances of the same master
later on. This same point applies to your "last" page masters, which
should only be necessary if the layout of the final page in your series
of foldout pages needs to be different from all of the others.
Here's a big area where my lack of XSL-FO experience comes in. From a
quick look over the XSL-FO specification, I don't believe you're allowed
to specify "odd-or-even" or "page-position" attributes on
<fo:single-page-master-reference/> or
<fo:repeatable-page-master-reference/> elements. The spec only shows
these on the <fo:conditional-page-master-reference/> element. The idea
is that the "single" element will match the next page regardless of any
conditions and that the "repeatable" element will similarly match all
pages, up to the limit specified in the "maximum-repeats" attribute.
For a sequence of pages that needs to shift among two or more masters,
such as alternating even and odd, the
<fo:repeatable-page-master-alternatives/> is used, with each
"conditional" element specifying the conditions under which its
specified master is used. The selection process stops at the first
match, meaning that the more restrictive conditions need to be listed
first, such as page-position="last" coming before an
otherwise-equivalent page-position="any". Given all that, I'd rewrite
your example as follows:
<fo:page-sequence-master master-name="foldout-page">
<fo:single-page-master-reference<br/>master-reference="first-foldout-master"/>
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference<br/>master-reference="foldout-master-even" odd-or-even="even"
page-position="last"/>
<fo:conditional-page-master-reference<br/>master-reference="foldout-master-odd" odd-or-even="odd"
page-position="last"/>
<fo:conditional-page-master-reference<br/>master-reference="even-foldout-master" odd-or-even="even"
page-position="any"/>
<fo:conditional-page-master-reference<br/>master-reference="odd-foldout-master" odd-or-even="odd"
page-position="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
Now, this does not specify that the first page needs to be odd-numbered.
That, I believe, would be accomplished via appropriate use (exact use
left as an exercise, or future Adepters question, for the reader) of the
"initial-page-number" and "force-page-count" attributes on the page
sequences for foldouts and the chapter preceding it. Also, I notice
that you don't seem to have a "blank" master, which I would expect in
this type of sequence so that things come out right if your last foldout
ends up on an odd page. However, such a master is not necessary if your
blank page looks just like any other even-numbered page, but without any
content (other than page numbers and such).
Hope this helps.
-Brandon 🙂