473,401 Members | 2,068 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,401 software developers and data experts.

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:attribute name="class">color<xsl:value-of
select="normalize-space(Publisher)"/></xsl:attribute>

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

Dec 12 '06 #1
4 2698
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*********@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.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:attribute name="class">color<xsl:value-of
select="normalize-space(Publisher)"/></xsl:attribute>

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

Dec 12 '06 #2
ko*********@gmail.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:attribute name="class">color<xsl:value-of
select="normalize-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:attribute name="class">color<xsl:value-of
select="translate(Publisher, ' ', '')"/></xsl:attribute>

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

<xsl:attribute name="class">color<xsl:value-of
select="translate(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*********@gmail.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:attribute name="class">color<xsl:value-of
select="normalize-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:attribute name="class">color<xsl:value-of
select="translate(Publisher, ' ', '')"/></xsl:attribute>

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

<xsl:attribute name="class">color<xsl:value-of
select="translate(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
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...
1
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...
4
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 ...
1
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...
13
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...
5
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...
8
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...
5
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
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'...
1
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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
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.