[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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) > 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:choose> <xsl:when test="string-length($Text) > 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) > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|