RE: [xsl] Long string - inserting a space after every 10 characters

Subject: RE: [xsl] Long string - inserting a space after every 10 characters
From: "Kenny Akridge" <kakridge@xxxxxxxxxxxxx>
Date: Wed, 4 Feb 2004 02:41:08 -0500
I'm sure there is an easier solution that I'm not aware of, but this
will certainly work:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<xsl:template match="/">
	<xsl:apply-templates select="name">
		<xsl:with-param name="count" select="'11'"/>

<xsl:template match="name">
	<xsl:param name="count"/>
		<xsl:when test="$count &lt; string-length(.) ">
			<xsl:value-of select="substring(., ($count -
10), 10)"/>
			<xsl:apply-templates select="//name">
				<xsl:with-param name="count"
select="$count + 10"/>
			<xsl:value-of select="substring(., ($count -
10), 10)"/>

Just substitute &#160; or &#xA0; for <br/> if you want spaces.

-Kenny Akridge

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
Sent: Wednesday, February 04, 2004 1:59 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Long string - inserting a space after every 10 characters


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

I have an XML element called <name> which can be anywhere between 1 and
characters long. I need to either split it (by inserting a <BR/> tag) or
inserting a space (&#160;) after every 10 characters.


Would look like:

OR /


Would loook like:

Many, many thanks

Important:  This e-mail is intended for the use of the addressee and may
contain information that is confidential, commercially valuable or
subject to legal or parliamentary privilege.  If you are not the
intended recipient you are notified that any review, re-transmission,
disclosure, use or dissemination of this communication is strictly
prohibited by several Commonwealth Acts of Parliament.  If you have
received this communication in error please notify the sender
immediately and delete all copies of this transmission together with any

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread