473,573 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The normalize-space

Hi all

I'm trying to get a value from an xml node 'Publisher' use the value as
a name of an .css class. This works fine until I get a value from the
Publisher node with white space in it.
I've been trying to use normalize-space function on this but I can't
make this work

here is what I'm trying to do

<xsl:attribut e name="class">co lor<xsl:value-of
select="normali ze-space(Publisher )"/></xsl:attribute>

Can anyone help me, I've spent to much time on this already..
Thanks
K.

Dec 12 '06 #1
4 2713
normalize-space doesn't remove spaces, just trims off the ends and compacts
multiple whitespace to a single character.
Perhaps you can use translate(' ', '_') to change all spaces to an
underscore, maybe after normalize-space?

--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name

<ko*********@gm ail.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.com.. .
Hi all

I'm trying to get a value from an xml node 'Publisher' use the value as
a name of an .css class. This works fine until I get a value from the
Publisher node with white space in it.
I've been trying to use normalize-space function on this but I can't
make this work

here is what I'm trying to do

<xsl:attribut e name="class">co lor<xsl:value-of
select="normali ze-space(Publisher )"/></xsl:attribute>

Can anyone help me, I've spent to much time on this already..
Thanks
K.

Dec 12 '06 #2
ko*********@gma il.com wrote:
I'm trying to get a value from an xml node 'Publisher' use the value as
a name of an .css class. This works fine until I get a value from the
Publisher node with white space in it.
I've been trying to use normalize-space function on this but I can't
make this work

here is what I'm trying to do

<xsl:attribut e name="class">co lor<xsl:value-of
select="normali ze-space(Publisher )"/></xsl:attribute>
CSS class names can't contain white space, if you end up with e.g.
<div class="class name">
then the div elements belongs to two classes, one with name "class", the
second with name "name".

If you want to strip spaces from Publisher then use e.g.

<xsl:attribut e name="class">co lor<xsl:value-of
select="transla te(Publisher, ' ', '')"/></xsl:attribute>

If you want to use '-' instead of space then you could do e.g.

<xsl:attribut e name="class">co lor<xsl:value-of
select="transla te(normalize-space(Publisher ), ' ', '-')"/></xsl:attribute>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 12 '06 #3

ML wrote:
Could you give an example of the value in Publisher?
ML

---
http://milambda.blogspot.com/
Hi
The value is 'Pan vision' and I have to remove the whitespace or
replace it with _ so it will be 'PanVision' or 'Pan_Vision'.

Dec 12 '06 #4
Thanks Martin - this works like a charm :o)

Martin Honnen wrote:
ko*********@gma il.com wrote:
I'm trying to get a value from an xml node 'Publisher' use the value as
a name of an .css class. This works fine until I get a value from the
Publisher node with white space in it.
I've been trying to use normalize-space function on this but I can't
make this work

here is what I'm trying to do

<xsl:attribut e name="class">co lor<xsl:value-of
select="normali ze-space(Publisher )"/></xsl:attribute>

CSS class names can't contain white space, if you end up with e.g.
<div class="class name">
then the div elements belongs to two classes, one with name "class", the
second with name "name".

If you want to strip spaces from Publisher then use e.g.

<xsl:attribut e name="class">co lor<xsl:value-of
select="transla te(Publisher, ' ', '')"/></xsl:attribute>

If you want to use '-' instead of space then you could do e.g.

<xsl:attribut e name="class">co lor<xsl:value-of
select="transla te(normalize-space(Publisher ), ' ', '-')"/></xsl:attribute>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4134
by: Christos TZOTZIOY Georgiou | last post by:
I found at least one case where decombining and recombining a unicode character does not result in the same character (see at end). I have no extensive knowledge about Unicode, yet I believe that this must be a problem of the Unicode 3.2 specification and not Python's. However, I haven't found out how the decomp_data (in unicodedata_db.h)...
1
5994
by: Daniel Lim | last post by:
When using XmlSerializer, I notice that it does not normalize the single quote and double quote characters, i.e. does not change ' to &apos; and " to &quot. However, it does normalize other characters, like changing ampersand to &amp; Here is my code: ---- start of code -------- MyClass *myClass = MyClass() ; XmlSerializer *xs = new...
4
1920
by: Nathan Benefield | last post by:
I currently have a spreadsheet tracking votes on legislation in a matrix type format. It is something like this Name Act1 Veto1 Act1A Jones yes No Yes Johnson Yes Yes Ex. Only with many more members and bills. I want to normalize this so that i can create reports by both Bill and by member - linking it...
1
7590
by: jandhondt | last post by:
IN Visual Studio 2005 with VB.NET when I open a solution I often get this warning: The line endings in the following file are not consistent. Do you want to normalize the line endings? The warning occurs on an inherited form. My solution is under Source control with Visual Sourcesafe. No matter if I answer Yes or no, the next time it will...
13
2183
by: WardC | last post by:
I'm a FileMaker user trying to help a client with an Access data entry problem: When text is copied from another application and pasted into an Access form, the pasted text sometimes includes unwanted characters (e.g., leading or trailing whitespace, embedded carriage returns, punctuation). We'd like to automatically normalize the pasted...
5
10344
by: =?iso-8859-1?B?TWF0dGlhcyBCcuRuZHN0cvZt?= | last post by:
Hello! I'm trying to find what package I should use if I want to: 1. Create 3d vectors. 2. Normalize those vectors. 3. Create a 3x3 rotation matrix from a unit 3-d vector and an angle in radians. 4. Perform matrix multiplication.
8
2995
by: bbcrock | last post by:
I have three tables with a relationship I've never worked with before. Can anyone suggest/comment on the best way to create a third normal form relationship between these tables? The tables basically are: TRAIN (TRAIN_ID and 15 columns about train specs, etc) TRUCK (TRUCK_ID and 12 columns about truck specs, etc) TRANSPORTATION_ITEM...
5
1786
dmjpro
by: dmjpro | last post by:
Please explain me the job of Node.normalize(). I read out the docs but i don't understand. Please help me to understand. Kind regards, Dmjpro.
9
4270
by: Peter Bengtsson | last post by:
In UTF8, \u0141 is a capital L with a little dash through it as can be seen in this image: http://static.peterbe.com/lukasz.png I tried this: '' I was hoping it would convert it it 'L' because that's what it visually looks like. And I've seen it becoming a normal ascii L before in other programs such as Thunderbird.
1
5468
by: asharda | last post by:
Hi, I have to write a program which will calculate the PEAK and Normalize the audio files. I already have a class which returns an array of in for a given wave file. Does anyone know how I can get the PEAK value in decibels instead of integer or double?
0
7760
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7679
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7996
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8049
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6392
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5573
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3723
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1289
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.