Re: [xsl] Elegant way to create an empty line

Subject: Re: [xsl] Elegant way to create an empty line
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 05 Jul 2009 08:06:57 -0400
At 2009-07-05 13:58 +0200, Jan Hoeft wrote:
is there an elegant way to create empty lines using block elements?

My template is quite simple:

<xsl:template match="p">
  <fo:block>
     <xsl:apply-templates/>
  </fo:block>
</xsl:template>

How do I tell FO to create a new line for each <p/>?

Do you mean to leave a blank between the previous block and this block?


<fo:block space-before="1em">

Do you mean to leave a blank between this block and the next block?

<fo:block space-after="1em">

In both cases, when that space is at the very beginning or very end of a reference area (say a column), the space is discarded. This is very helpful when displaying continuous blocks across multiple columns/pages.

If, however, you are asking about creating an empty line regardless of the content of the element, that would be:

<fo:block><fo:leader/></fo:block>

This is more elegant than using a non-breaking space or other special graphic character. And more elegant than using regular spaces in combination with properties that prevent their collapse.

But I am unclear about your question in that you are asking about empty lines yet your template is quite obviously adding the content of your paragraph to the result tree.

I hope this helps.

. . . . . . . . . . . . . Ken


-- Possible July/August XSLT/XQuery/XSL-FO training in Oakland/CA/USA Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread