Search code examples
xmlxsltxsl-fo

XSL:FO flowing inline quotations


I am outputting an XML document to PDF using XSL:FO (XEP).Everything works very well, except when I introduce quotation marks. For some reason, phrases with quotation marks do not 'flow'. This is best evidenced in the picture:

problem with text flow

The source xml looks like this:

<seg>Item. Dixit quod P[etrus] Gauta loqutus est 
  publice Bernardo, domino del Mas, contra 
  ipsum testis in hunc modum <quote>Bernarde del Mas, 
  est ne bonum quod aliquis qui detexerit nos eat vivus 
  super terram?</quote> Et propter illa verba, ipse testis cum 
  familia sua exivit de Manso.</seg>

<seg>Item. Dixit quod Iordanus de Quiders 
  dixit <quote>Nuper ipsi testis modo apparebit quis 
  expeditus erit citius vos qui provenistis alios in 
  confessione</quote>. Et abiuravit heresim et 
  iuravit et cetera. Testes: Arnaldus, prior Sancti 
  Saturnini; et magister P[etrus] de Caramag; 
  et frater B[ernardus], inquisitor.</seg>

The XSL:FO is quite simple. The <quote>element is replaced with "

<xsl:template match="quote">
    <fo:inline><xsl:text>"</xsl:text><xsl:apply-templates/><xsl:text>"</xsl:text></fo:inline>
</xsl:template>  

It is activated with a simple fo:flow (and the rest of the text flows with zero flow problems):

<!-- content flow -->
<fo:flow flow-name="xsl-region-body" font-family="Times" font-weight="normal" font-size="10pt">
     <xsl:apply-templates/>
</fo:flow>

Is there a special way to handle quotation marks inline?

---- ADDED ----

This is the template that treats the <seg> element, forcing each into a new paragraph.

<xsl:template match="seg">
    <xsl:for-each select=".">
        <fo:block
            font-family="Times" font-weight="normal" line-height="12pt" line-stacking-strategy="font-height" keep-together="always" 
            font-size="10pt" space-before="10pt" space-after="10pt" text-align="justify" end-indent="120pt">
            <xsl:apply-templates/>
        </fo:block>
    </xsl:for-each>
</xsl:template>

Thanks in advance.


Solution

  • Change keep-together to keep-together.within-page. Currently, you're forcing the fo:inline to keep together within one line. See https://www.w3.org/TR/xsl11/#keep-together.

    Strictly speaking, you don't even need the fo:inline since you're not adding or changing any properties with the fo:inline. You might also want to use 'curly quotes' ( and ) to improve the appearance of your text.