[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Keeping Text Together


Subject: Re: [xsl] Keeping Text Together
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 21:16:14 -0400

At 2010-06-14 17:46 -0700, siarom egrub wrote:
Thanks for taking the time to response to my post. Yes, I have tried using <block keep-together.within-column="always"> and the result is the same as detailed below.

Probably because of how you are handling your <br> element with the explicit break:


Here is how the "<br>" element is handled:

<!--=======+Line break (br) template+=======-->
<xsl:template match="br">
    <fo:block break-after="auto">
      <xsl:choose>
        <xsl:when test="parent::productname">
          <fo:block keep-together.within-column="always">
             <xsl:apply-templates/>
          </fo:block>
       </xsl:when>
       <xsl:otherwise>
          <xsl:apply-templates/>
       </xsl:otherwise>
      </xsl:choose>
    </fo:block>
</xsl:template>

The XSL-FO specification states that an explicit break will break an explicit keep.


Your code also reveals a misunderstanding regarding XSLT ... since you imply in an earlier post that <br/> is always empty, using <xsl:apply-templates/> does nothing because you implicitly are pushing child nodes to your stylesheet and <br/> has no child nodes.

You may find the following will work for you:

 <xsl:template match="br">
   <fo:block/>
 </xsl:template>

The simple block will break the line, but it isn't an explicit break so it won't break the keep.

I hope this helps.

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

--
XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
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
Keywords