Replacing multiple spaces after last word

wxdqz

New Member
Hi Guys

I hope this is a simple one for you.

I am basically displaying data onto my xml page using the following line of code:

<xsl:value-of select="carmanufacturer" />

An example of the resulting output would be, "Ford"

However, the "carmanufacturer" field in my table sometimes contains 2 words, for example, "Land Rover". Thus, the resulting output is, "Land Rover".

The output on my page is also hyperlinked and so the code is as follows:

<a class="type1" href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.mywebsite.co.uk/{carmanufacturer}.asp"><xsl:value-of select="carmanufacturer" /></a>

The need the hyperlink url I would like to replace the spaces between the 2 words with a "-". Thus my link would point to:

<!-- m --><a class="postlink" href="http://www.mywebsite.co.uk/Land-Rover.asp">http://www.mywebsite.co.uk/Land-Rover.asp</a><!-- m -->

So I used."{translate(carmanufacturer,' ','-')}" to achieve this. Thus,

<a class="type1" href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.mywebsite.co.uk/{translate(carmanufacturer,' ','-')}.asp"><xsl:value-of select="carmanufacturer" /></a>

However, the problem I have now is that some of the data within my field contains many spaces after the final word. For example

"land rover "

How would it get this data to appear in my hyperlink without the spaces at the end of the last word, so it displays as:

<!-- m --><a class="postlink" href="http://www.mywebsite.co.uk/Land-Rover.asp">http://www.mywebsite.co.uk/Land-Rover.asp</a><!-- m --> and not <!-- m --><a class="postlink" href="http://www.mywebsite.co.uk/Land-Rover">http://www.mywebsite.co.uk/Land-Rover</a><!-- m --> .asp

PS: Unfortunately, I do not have access to my database and therefore unable to change the format of the table/fields etc. Thus, I have to make this work at script level.

Any help would be fully appreciated.

Rod from the UK
 
Back
Top