I want an initial at the first line of a paragraph and a text-indent for all the other paragraphs. I'm using the following code:
<xsl:template match="paragraph">
<xsl:choose>
<!-- no text-indent, first letter bigger -->
<xsl:when test="fn:position() = 1">
<fo:block font-size="10pt" font-height="12pt">
<fo:inline font-size="18pt"><xsl:value-of
select="substring(.,1,1)"/></fo:inline>
<xsl:value-of select="substring(.,2)"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<!-- text-indent -->
<fo:block line-height="12pt"
text-indent="10pt">
<xsl:value-of select="."/></fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This works, but the line-height of the first line is enlarged and there is to much space between the lines.
line-height-attributes or <fo:initial-property-set>
don't work.
Thanks a lot.
Edit: I'm using fop
Edit: FOP doesn't support <fo:float>
or <fo:initial-property-set>
. I tried another code using <fo:list>
:
<xsl:when test="fn:position() = 1">
<fo:block font-family="Times" font-size="10pt" line-height="12pt">
<fo:list-block>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="18pt"><xsl:value-of select="substring(.,1,1)"/></fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block><xsl:value-of select="substring(.,2)"/></fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
</xsl:when>
The result looks like this:
So i used figure space  
in the value-of select pattern of the <fo:list-item-body>
:
<xsl:when test="fn:position() = 1">
<fo:block font-family="Times" font-size="10pt" line-height="12pt">
<fo:list-block>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="18pt"><xsl:value-of select="substring(.,1,1)"/></fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block><xsl:value-of select="(' ', ' ', substring(.,2))"/></fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
</xsl:when>
This isn't just dowdy, it also doesn't work really good:
Does anyone have a solution?
This xsl snippet, minimally revised from the first one in the question, produces the desired result using Apache FOP:
<xsl:template match="paragraph">
<xsl:choose>
<!-- no text-indent, first letter bigger -->
<xsl:when test="not(preceding-sibling::paragraph)">
<fo:block line-height="12pt"
line-stacking-strategy="font-height">
<fo:inline font-size="18pt"><xsl:value-of
select="substring(.,1,1)"/></fo:inline>
<xsl:value-of select="substring(.,2)"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<!-- text-indent -->
<fo:block line-height="12pt"
text-indent="10pt">
<xsl:value-of select="."/></fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Important points:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With