|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Long string - inserting a space after every 10 cha
Hi, > Is it possible to insert a space in a string (of unknown > length) after a > specified number of characters e.g. after every 10 characters insert a > space?? > > I have an XML element called <name> which can be anywhere > between 1 and 50 > characters long. I need to either split it (by inserting a > <BR/> tag) or > inserting a space ( ) after every 10 characters. > > Example1: > <name>Thisisareallyreallylongnamedontyouthink</name> > > Would look like: > Thisisarea<BR/>llyreallyl<BR/>ongnamedon<BR/>tyouthink <xsl:template match="name" name="chop"> <xsl:param name="text" select="."/> <xsl:param name="delimiter"> <br/> </xsl:param> <xsl:param name="length" select="10"/> <xsl:choose> <xsl:when test="string-length($text) > $length"> <xsl:value-of select="substring($text, 1, $length)"/> <xsl:copy-of select="$delimiter"/> <xsl:call-template name="chop"> <xsl:with-param name="text" select="substring($text, $length + 1)"/> <xsl:with-param name="delimiter"> <xsl:copy-of select="$delimiter"/> </xsl:with-param> <xsl:with-param name="length" select="$length"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> Cheers, Jarno - Tactical Sekt: Xfixiation (Myer Burns the Dancefloor mix by Haujobb) 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
|






