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

Replace function?

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="http://www.mywebsite.co.uk/{carmanufacturer}.asp"><xsl:value-of select="carmanufacturer" /></a>

The problem I have is that for the hyperlink url I would like to replace the spaces between the 2 words with a "-". Thus my link would point to:

http://www.mywebsite.co.uk/Land-Rover.asp

I have tried using something like this "<xsl:value-of select="replace(carmanufacturer, ' ', '-')" />" but I get the following error:

-------------error----------------
msxml3.dll error '80004005'

'replace' is not a valid XSLT or XPath function. -->replace(carmanufacturer, ' ', '-')<--
--------------error end------------

Looking at various forums they say this error occurs because I have XSLT 1.0 and not XSLT 2.0 but I am unsure what version I've got. If the code I am using should work then I assume that I have version 1.0??? However, I do not know what code I need to use to make this work.

Any ideas would be fully appreciated.

Best regards

Rod from the UK
Sep 20 '07 #1
Share this Question
Share on Google+
2 Replies


jkmyoung
Expert 100+
P: 2,057
In xpath, the function is translate
http://www.w3schools.com/xpath/xpath...ons.asp#string
Sep 20 '07 #2

P: 36
Hi JKMYoung

Thank you for your help.

The translate functon worked perfectly!

Best regards Rod
Sep 22 '07 #3

Post your reply

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