Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 2nd, 2006, 06:58 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Blank Space in XSLT

Hi everybody,

How to create a blank space in XSLT? I used #160; When I use .NET iT displays  Character in the blank sapce
 I have tried
#x20; and it does not produce ? but does not create a space.

Please Help me

Reply With Quote
  #2 (permalink)  
Old February 2nd, 2006, 07:39 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

You can create a single space using

<xsl:text> </xsl:text>

or if you prefer greater visibility,

<xsl:text>#x20;</xsl:text>

Note that if you are generating HTML, multiple spaces in the HTML file will display as a single space in the browser.

You can create a non-breaking space using

#xa0; (or #160;)

This does not require an xsl:text element because it is not treated as whitespace by the XSLT processor.

If the non-breaking space displays incorrectly when you view the resulting HTML (either in a browser or in a text editor - you didn't say which) then this is because your configuration is set up incorrectly. It looks as if you have generated the HTML in UTF-8 encoding, and have then displayed it using software that thinks the encoding is iso-8859-1 or something similar (perhaps Microsoft cp1252).

One way to avoid such encoding problems is to specify <xsl:output encoding="us-ascii">. This will force a non-ASCII character such as NBSP to be output as a chararacter reference or entity reference.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old April 9th, 2012, 02:20 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Talking Blank Space - this worked for me

<xsl:text disable-output-escaping="yes"> <![CDATA[&nbsp;]]> <![CDATA[&nbsp;]]> <![CDATA[&nbsp;]]><![CDATA[&nbsp;]]> <![CDATA[&nbsp;]]><![CDATA[&nbsp;]]> <![CDATA[&nbsp;]]> <![CDATA[&nbsp;]]></xsl:text>

Each <![CDATA[&nbsp;]]> creates one blank space. I tried all the other suggestions on the internet and this was the only one that worked for me. I hope this helps!

Reply With Quote
  #4 (permalink)  
Old April 9th, 2012, 02:29 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

I don't know if you were intentionally contributing to a thread that's been dormant for six years. But in any case, your contribution is unhelpful; this mess of disable-output-escaping and CDATA is totally unnecessary.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i trim space using XSLT? Mitali XSLT 5 July 25th, 2008 03:15 PM
Handle Null or Blank values using xslt in csv data mums XSLT 1 April 3rd, 2008 07:30 PM
Strangely working XSLT function normalize-space() seetaramayya XSLT 2 April 23rd, 2007 06:26 AM
space crmpicco Javascript How-To 1 February 7th, 2005 01:26 PM
Blank space in details section Suren Crystal Reports 1 October 27th, 2004 04:14 AM



All times are GMT -4. The time now is 04:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.