Re: AW: AW: AW: [xep-support] XSLFO: trouble with text-align-last="justify" and linefeed-treatment="preserve"

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Mon Jan 21 2008 - 12:02:30 PST

At 2008-01-21 18:45 +0100, Kirch Fritz wrote:
>Do you have at least an example how to tokenize the name node texts
>at CRLF with XSLF 1.0 in order to build my blocks as intended?

I read the above as "XSL-FO 1.0", not "XSLT 1.0" ... sorry ... below
is an example using XSLT 1.0.

Tokenization is accomplished using substring-before and
substring-after in a recursive template call. A common design
pattern for XSLT 1.0 that is rarely needed when using XSLT 2.0.

I hope this helps.

. . . . . . . . . Ken

T:\ftemp>type fritz.xml
<AddressList>
<Address>
   <name>a very long text
having CRLF
characters</name>
   <phonenumber>12345</phonenumber>
</Address>
<Address>
   <name>short text</name>
   <phonenumber>12345</phonenumber>
</Address>
</AddressList>

T:\ftemp>type fritz.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">

<xsl:output indent="yes"/>

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

<xsl:template match="Address">
   <blocks-for-an-address>
     <xsl:call-template name="tokenize-blocks">
       <xsl:with-param name="text" select="name"/>
       <xsl:with-param name="suffix" select="phonenumber"/>
     </xsl:call-template>
   </blocks-for-an-address>
</xsl:template>

<xsl:template name="tokenize-blocks">
   <xsl:param name="text"/>
   <xsl:param name="suffix"/>
   <xsl:choose>
     <xsl:when test="contains($text,'&#xa;')">
       <block>
         <xsl:value-of select="substring-before($text,'&#xa;')"/>
       </block>
       <xsl:call-template name="tokenize-blocks">
         <xsl:with-param name="text" select="substring-after($text,'&#xa;')"/>
         <xsl:with-param name="suffix" select="$suffix"/>
       </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <block text-align-last="justify">
         <xsl:value-of select="$text"/>
         <leader leader-pattern="dots"/>
         <xsl:apply-templates select="$suffix"/>
       </block>
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>xslt fritz.xml fritz.xsl con
<?xml version="1.0" encoding="utf-8"?>

<blocks-for-an-address>
    <block>a very long text </block>
    <block>having CRLF </block>
    <block text-align-last="justify">characters<leader
leader-pattern="dots"/>12345</block>
</blocks-for-an-address>

<blocks-for-an-address>
    <block text-align-last="justify">short text<leader
leader-pattern="dots"/>12345</block>
</blocks-for-an-address>

T:\ftemp>

--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
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)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/f/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
Received on Mon Jan 21 12:56:55 2008

This archive was generated by hypermail 2.1.8 : Mon Jan 21 2008 - 12:56:56 PST