473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Replacing multiple spaces after word in field

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 need 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

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

<a class="type1" href="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:

http://www.mywebsite.co.uk/Land-Rover.asp and not http://www.mywebsite.co.uk/Land-Rover .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
2 2003
rjoseph
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:

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

'trim' is not a valid XSLT or XPath function
---------------end---------------------

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
jkmyoung
2,057 Expert 2GB
normalize-space()

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

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

Similar topics

4
by: r0adh0g | last post by:
I am attempting to build a primitive search form on my site. It is searching an Access Database Table and comparing on field in the database to a field passed from the form. Works great if only...
7
by: Jason | last post by:
When users fill out my text area field, there is a chance that there will be no line feeds or cariage returns or spaces and just one really long word. THIS CAUSES A MAJOR PROBLEM! What I am trying...
2
by: Jerome | last post by:
Hi, I know this is an old question but I don't find the solution on the 'net ... The user enters his data into a multiline textarea field. The data is saved in a TEXT field in a database on a...
13
by: a.zeevi | last post by:
free() multiple allocation error in C ==================================== Hi! I have written a program in C on PC with Windows 2000 in a Visual C environment. I have an error in freeing...
1
by: BethanyBez | last post by:
Is there any way when doing a merge with an Access Query and a columned Word doc that I can avoid blank spaces where the field is blank? I am creating a columned contact sheet with the contacts...
5
by: vonclausowitz | last post by:
Repost from an VB group. Hi All, I'm looking for a way to search for multiple words in a database. There is however one but. The words have to be within a certain range of each other. For...
19
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48...
10
by: H | last post by:
Hi, I have the following address fields in a table: flat_number house_name_or_number street village postal_town county postcode
3
by: bstjean | last post by:
Hi everyone, I am trying to find an efficient way to perform a special query. Let me explain what I want. Let's say we are looking for all description that match "this is the target". In...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.