title: XLSFO: floating images, full-page images
body: <p>I'm using Apache <code>fop</code> 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.).</p>
  
  <p>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).</p>
  
  <p>The contents XML is supposed to contain elements like <code>&lt;fullpageimg path="img/000_cover.png"&gt;</code> and <code>&lt;inlineimg path="img/001_face.png"&gt;</code>.  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.</p>
  
  <p>The template I'm using for the inline images is straight forward and looks something like this:</p>
  
  <pre><code>  &lt;xsl:template match="inlineimg"&gt;
      &lt;fo:block text-align="center"&gt;
        &lt;fo:external-graphic&gt;
          &lt;xsl:attribute name="src"&gt;
            &lt;xsl:value-of select="@path"/&gt;
          &lt;/xsl:attribute&gt;
        &lt;/fo:external-graphic&gt;
      &lt;/fo:block&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>And this also works as expected.  The images appear as their own paragraph as they are supposed to.</p>
  
  <p>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.</p>
  
  <pre><code>  &lt;xsl:template match="fullpageimg"&gt;
      &lt;fo:block text-align="center"&gt;
      &lt;fo:float float="left"&gt;
      &lt;fo:block text-align="center"&gt;
        &lt;fo:external-graphic&gt;
          &lt;xsl:attribute name="content-width"&gt;
            &lt;xsl:value-of select="@width"/&gt;
          &lt;/xsl:attribute&gt;
          &lt;xsl:attribute name="src"&gt;
            &lt;xsl:value-of select="@path"/&gt;
          &lt;/xsl:attribute&gt;
        &lt;/fo:external-graphic&gt;
      &lt;/fo:block&gt;
      &lt;/fo:float&gt;
      &lt;/fo:block&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>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).</p>
  
  <p>I also tried enclosing parts of it in elements like these:</p>
  
  <pre><code>  &lt;fo:block-container absolute-position="absolute" width="214mm" height="301mm"&gt;
      &lt;fo:block-container overflow="error-if-overflow" width="214mm" height="301mm"&gt;
        ...
      &lt;/fo:block-container&gt;
    &lt;/fo:block-container&gt;
  </code></pre>
  
  <p>But that also doesn't produce the results I'm looking for (the outcome varies and depends on where I insert these, often the <code>fop</code> also complains about an error in the input).</p>
  
  <p>The main template of my XSL looks something like this:</p>
  
  <pre><code>  &lt;xsl:template match="/doc"&gt;
      &lt;fo:root&gt;
        &lt;fo:layout-master-set&gt;
          &lt;fo:simple-page-master ...&gt;
            ...
          &lt;/fo:simple-page-master&gt;
          &lt;fo:page-sequence-master master-name="document"&gt;
            ...
          &lt;/fo:page-sequence-master&gt;
        &lt;/fo:layout-master-set&gt;
        &lt;fo:page-sequence master-reference="document"&gt;
          ...
          &lt;fo:flow ...&gt;
            &lt;xsl:apply-templates/&gt;
          &lt;/fo:flow&gt;
        &lt;/fo:page-sequence&gt;
      &lt;/fo:root&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>If there is any more information needed I can provide it of course.</p>
  
  <p>What's the correct way of doing this?  Is it maybe necessary to change the main template?  I'm using <code>fop</code> 2.4 which is supposed to be able to handle <code>fo:float</code> correctly if given only simple things like  <code>float="left"</code>.</p>