« Return to Thread: keep-together.within-column

Re: keep-together.within-column

by Vincent Hennebert-2 :: Rate this Message:

Reply to Author | View in Thread

Hi Sandra,

sandraB wrote:
> Hi,
> I'm facing another issue. I keep my solution but with yours it will be the
> same problem:
> I transform the text() node by replacing the '.' with '\u200B'. But how can
> I call the <xsl:apply-templates> on the result (I can have some bold text
> text or italic text text in a table cell) ?

I’m no XSLT specialist, but I’d play a bit more with XPath: “transform
every text node that is a descendant of a td element”:

     <xsl:template match="td//text()">
         <xsl:call-template name="addZeroWidthSpace" select="."/>
     </xsl:template>

If you have something like <td>Text with <b>bold</b> fragment</td>, the
above template will be called 3 times: on “Text with ”, “bold” and
“ fragment”.

In the template matching td you can replace the call to
addZeroWidthSpace with a simple <xsl:apply-templates/>.



> My templates
>
> <xsl:template match="td">
>  <fo:table-cell overflow="visible" keep-together.within-column="always">
>    <fo:block padding="0cm" white-space-collapse="false">
>     <xsl:call-template name="addZeroWidthSpace" >
> <xsl:with-param name="str" select="text()" />
> </xsl:call-template>
>    </fo:block>
>   </fo:table-cell>
> </xsl:template>
> <xsl:template name="addZeroWidthSpace">
> <xsl:param name="str" />
> <xsl:variable name="hyphenation-character">​</xsl:variable>
> <xsl:choose>
> <xsl:when test="'.' and contains($str, '.')">

Why are you testing for '.'? It seems to me that you can simply do
     <xsl:when test="contains($str, '.')">

>                                <!-- I need to apply another templates on
> substring-before($str, '.')  -->
> <xsl:value-of select="substring-before($str, '.')" />.<xsl:value-of
> select="$hyphenation-character" />
> <xsl:call-template name="addZeroWidthSpace">
>   <xsl:with-param name="str" select="substring-after($str, '.')" />
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
>                                <!-- I need to apply another templates here
> -->
> <xsl:value-of select="$str" />
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>

If you still have trouble getting your stylesheet right, I suggest you
to ask on the Mulberry Tech XSL list:
http://www.mulberrytech.com/xsl/xsl-list/index.html
You will have more chance to find XSLT specialists who will be able to
help you.


HTH,
Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...

 « Return to Thread: keep-together.within-column