This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

text string handling or wrap


Hi friends,
I have a small problem.
I have Text node with an string and when i am displaying it in tablecell 
i.e. <td> on client.The problem
is,If any word increases more then 30 letters it dosnt wrap the text and 
table get deformed.to tackle it
I used an template which is as follows

<xsl:template name="textwrap">
	<xsl:param name="Text"/>
<xsl:value-of select="substring($Text, 1, 30)"/>
<br></br>
  <xsl:variable name="rest" select="substring($Text, 31)" />
  <xsl:if test="string-length($rest) &gt; 30">
    <xsl:call-template name="textwrap">
      <xsl:with-param name="Text" select="$rest" />
    </xsl:call-template>
  </xsl:if>

</xsl:template>

But As I am using old verson of saxon(3.2)It dosnt support tail 
recursion.then I tried following


<xsl:template name="textwrap">
    <xsl:param name="Text"/>
    <xsl:variable name="linelen" select="30"/>

    <xsl:choose>
      <xsl:when test="string-length($Text) &gt; 30">
        <xsl:value-of select="substring(Text, 1, 30)"/>

        <br/>

        <xsl:call-template name="textwrap">
          <xsl:with-param name="Text" select="substring($Text, 31)"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$Text"/>
      </xsl:otherwise>
   </xsl:choose>
	 </xsl:template>
	 <xsl:template name="textwrapzz">
<xsl:param name="Text"/>
		<xsl:choose>
		<xsl:when test="$Text!=''">
			<xsl:choose>
			<xsl:when test="string-length($Text) &gt; 30">
			<xsl:value-of select="substring(Text, 1, 30)"/>
<br></br>
				<xsl:variable name="rest" select="substring(Text, 31)"/>
				<xsl:call-template name="textwrap">
					<xsl:with-param name="Text" select="$rest"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$Text"/>
			</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$Text"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

But This code is getting too long as string can be upto three hundred 
charector long.

So please any body can tell me how  i can find any word longer then 30 
charectors in a text string and
then break it in thirty letters words each without using recursion.
I will be really greatfull if some body provides me code example.
Thanks in anticipation.
your frienddly
ajrapa



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]