By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,078 Members | 1,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,078 IT Pros & Developers. It's quick & easy.

Replacing multiple spaces after word in field

P: 36
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="{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:

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

<a class="type1" href="{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: and not .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
Sep 21 '07 #1
Share this Question
Share on Google+
2 Replies

P: 36
Hi guys

In relation to my query in the first thread, I have tried the following line of code but it still doesn't work:

"{translate(trim(carmanufacturer,' ','-')}"

I get the following error:

msxml3.dll error '80004005'

'trim' is not a valid XSLT or XPath function

I think this is something to do with the fact that I have version XSLT 1.0 installed and not version 1.0, but I could be wrong?

Any help would be fully apprecaited.

Best regards

Rod Joseph
Sep 22 '07 #2

Expert 100+
P: 2,057

as posted in other forum.
take a look at, particularly the xpath functions section.
Sep 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.