[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

text string handling or wrap

Subject: text string handling or wrap
From: "ajay sinha" <sinhajay@xxxxxxxxxxx>
Date: Tue, 08 Jan 2002 14:39:19
xsl string handling
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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.