I'm using Apache fop to generate a PDF book out of an XML file describing the abstract contents (which I generate, so I have it under control) and an XSL file containing the formatting. Various XSL files are supposed to be used to generate various PDFs (manuscript, paperback, etc.).
I want to include images in the book's text, some of them are supposed to be full-page images near to a certain point in the text, and some are inline (centered between paragraphs).
The contents XML is supposed to contain elements like <fullpageimg path="img/000_cover.png"> and <inlineimg path="img/001_face.png">. The text in the XML before and after a fullpage image shall continue without interrupt, the image shall just appear on its own page close to the spot.
The template I'm using for the inline images is straight forward and looks something like this:
<xsl:template match="inlineimg">
<fo:block text-align="center">
<fo:external-graphic>
<xsl:attribute name="src">
<xsl:value-of select="@path"/>
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</xsl:template>
And this also works as expected. The images appear as their own paragraph as they are supposed to.
The full page images, however, I cannot figure out how to make work. I tried several things from several tutorials and example collections, e.g.
<xsl:template match="fullpageimg">
<fo:block text-align="center">
<fo:float float="left">
<fo:block text-align="center">
<fo:external-graphic>
<xsl:attribute name="content-width">
<xsl:value-of select="@width"/>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="@path"/>
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:float>
</fo:block>
</xsl:template>
This lets all fullpage images appear over each other (unintended) on page one (also unintended) of the PDF without making the text float around it (unintended as well), so the text also is going through the images (of course unintended).
I also tried enclosing parts of it in elements like these:
<fo:block-container absolute-position="absolute" width="214mm" height="301mm">
<fo:block-container overflow="error-if-overflow" width="214mm" height="301mm">
...
</fo:block-container>
</fo:block-container>
But that also doesn't produce the results I'm looking for (the outcome varies and depends on where I insert these, often the fop also complains about an error in the input).
The main template of my XSL looks something like this:
<xsl:template match="/doc">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master ...>
...
</fo:simple-page-master>
<fo:page-sequence-master master-name="document">
...
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="document">
...
<fo:flow ...>
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
If there is any more information needed I can provide it of course.
What's the correct way of doing this? Is it maybe necessary to change the main template? I'm using fop 2.4 which is supposed to be able to handle fo:float correctly if given only simple things like float="left".