W3C home > Mailing lists > Public > www-xsl-fo@w3.org > July 2003

Re: justifying lines with forced line breaks

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Wed, 09 Jul 2003 16:16:44 -0400
Message-Id: <>
To: www-xsl-fo@w3.org

At 2003-07-09 15:14 -0400, Matthew Gibson wrote:
>Quick question: I have a snippet of xml that looks like this--
><p>There was at the school to which I went,<lb/>
>a boy about twelve, the same age with myself.<lb/>
>His name was William Harding&mdash;he was the<lb/>
>only child of a widow lady, living a retired etc...</p>
>What I want to do is render the paragraph as fully justified but also
>respect the line-breaks (indicated by the linebreak tag)
>I tried the following:
><xsl:template match="p">
>    <fo:block font-size="12pt"
>                 font-family="serif"
>                 line-height="22pt"
>                 text-align="justify">
>   &#160;&#160;&#160;<xsl:apply-templates />
>          </fo:block>
>with the secondary rule:
><xsl:template match="lb">
>      <fo:block />
>The result I get, unfortunately, is a paragraph respecting line breaks but
>not fully justified.  Anyone have any ideas?

Use text-align-last="justify" because the introduction of the empty block 
elements makes the line ahead of <lb/> the last line of the previous block.

The property text-align= applies to all lines for all values *except* 
justify, when it only applies to the lines that aren't the last line.

Keep the text-align="justify" only if any of your lines might wrap ... if 
they will never wrap, then you don't need this property.

I hope this helps.

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

Upcoming hands-on courses: in-house corporate training available;
North America public:  XSL-FO Aug 4,2003; XSLT/XPath Aug 12, 2003

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/f/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X              Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:    http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
Received on Wednesday, 9 July 2003 16:16:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:09:58 UTC