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]

word wrap in text string


Hi MIchale,
thanks for time and effort,if possible can you give me a more detail example 
of extension function or pre/post processing like some code example or 
someting on web or book.I will be really thankfull.
I tried to use following code but it did'nt work because of recursion
<xsl:template name="textwrapzz">
	<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>
</xsl:stylesheet>
then i tried following
<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:value-of select="substring($rest, 1, 30)"/>
<br></br>
  </xsl:if>
	<xsl:variable name="resta" select="substring($rest, 31)" />
  <xsl:if test="string-length($resta) &gt; 30">
    <xsl:value-of select="substring($resta, 1, 30)"/>
<br></br>
  </xsl:if>
	<xsl:variable name="restb" select="substring($resta, 31)" />
  <xsl:if test="string-length($restb) &gt; 30">
    <xsl:value-of select="substring($restb, 1, 30)"/>
<br></br>
  </xsl:if>


</xsl:template>
but then again this also is dirty code as I dont know the size of text and 
it breaks the word.
Incase you have some thing better in mind please let me know.
Thanks.
Arup

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


 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]