Search code examples
xmlxsltxsl-fotei

XSL:FO how to 'flow' info separate from body into xsl-region-start and xsl-region-end


I have a medieval manuscript encoded in XML (using TEI schema). The manuscript has a 'body' which has been mapped in XSL:FO to xsl-region-body and outputs perfectly. The manuscript also features some 'glosses' (notes) in the left and right margins. These are marked up within the XML document using, for example <add type="margin_gloss" place="left">Some foo note</add>

I have reserved xsl-region-startand xsl-region-end to receive these margin glosses relative to their position in the original manuscript. However I am having trouble getting the marked up text to 'flow' into these regions.

Note: I have no problem putting hardcoded data into these regions with, for example, <fo:static-content flow-name="xsl-region-after">

The problem is that with the below code Apache FOP is telling me : For "fo:page-sequence", only one "fo:flow" may be declared.

        <fo:page-sequence master-reference="odd">
            <fo:static-content flow-name="xsl-region-after"
                font-family="Times"
                font-size="8pt">
                <fo:block text-align="center">-<fo:page-number/>-
                </fo:block>
            </fo:static-content>
            <fo:flow flow-name="xsl-region-end"
                font-family="Times"
                font-size="6pt">
                <xsl:call-template name="marginalia-right"/>
            </fo:flow>
            <fo:flow flow-name="xsl-region-body" 
                font-family="Times"
                font-size="8pt"
                space-before="8pt"
                space-after="8pt">
                <xsl:apply-templates/>
            </fo:flow>
        </fo:page-sequence>

I extract the notes with an XSL template:

 <xsl:template match="//tei:add[@type='margin_gloss' and @place='right']" name="marginalia-right">
      <fo:block>
          <xsl:value-of select="text()"/>
      </fo:block>
  </xsl:template>

To summarize the problem: I would like the margin glosses marked up in XML with <add> to appear in xsl-region-start and xsl-region-end positioned relative to line of text in xsl-region-body. FPO tells me I can't 'flow' twice.


Solution

  • You can't synchronize content in region-start with content in region-body.

    You can, however, place content in region-body and manipulate its position so it overlaps the region-start. XSL-FO provides the fo:float mechanism to do this.

    <fo:block --extra wide and a negative left margin to overlap the region-start>
        <fo:float> this contains the margin note</fo:float>
        <fo:block>this contains the body text linked to the note</fo:block>
    </fo:block>
    

    FOP has limited support for fo:float. Commercial FO processors (I use Antennahouse Formatter) offer full support.