Re: [xsl] concatinating a varying number of whitespace characters

Subject: Re: [xsl] concatinating a varying number of whitespace characters
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 19 Mar 2008 17:54:56 +0100
Adil Ladhani wrote:

I have a quick question about the concat() function. I need to
re-create a line from some XML, and the line should be of the format:
<Type><whitespace><Tail>

where <Type> and <Tail> are known, and the <whitespace> needs to be
detemined. <Tail> is always the same number of characters (i.e. 17)
and <Type> can vary in length. Since a line is always 40 characters, I
know that I need <Type> and <whitespace> to add up to 23 chars.
Furthermore,  I know I can determine the number of whitespace chars by
subtracting string-length(Type) from 23 (which is 40 - length(tail)),
but how can I use this within a concat?

Define a global parameter or variable with the maximum number of spaces e.g. <xsl:param name="forty-spaces" select="' '"/> then use substring to extract the number of spaces you need e.g. substring($forty-spaces, 1, 23 - string-length(Type))

Adil



--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread