Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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

  #2 (permalink)  
Old February 2nd, 2006, 07:39 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
  #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!

  #4 (permalink)  
Old April 9th, 2012, 02:29 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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


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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.